Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:51:55+00:00 2026-05-27T06:51:55+00:00

I am working on a gesture recognition project. There is a C program that

  • 0

I am working on a gesture recognition project. There is a C program that captures the gestures from video input and write them to the file. Now, I have an image viewer written in Python – GTK. It switches to the next or previous window according to gestures. This continuous file read and application update is defined as follows:

def ai(self):
        if self.mtime!=os.stat("input.txt").st_mtime:
            self.mtime=os.stat("input.txt").st_mtime
            inp=open("input.txt", "r");
            line=inp.read()
            if len(line)!=0:
                line=line[0:len(line)-1]
                for x in line.split(' '):
                    y=x.split('-')
                    if(y[1]=="R"):
                        self.next()
                        print "Move Right"
                    elif(y[1]=="L"):
                        self.prev()
                        print "Move Left"
        time.sleep(1)
        print "WakeUp"
        self.ai()

Now if I comment out the recursive call here, then application works after reading present file and updating images. Of course, then it doesn’t update afterwards.

But if I uncomment the recursive call, then the console keeps on working but image-viewer application stops responding.

Is there any way to perform this function? Any event where i could bind this ai() function that could check for file updates every time that event is fired…
Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:51:56+00:00Added an answer on May 27, 2026 at 6:51 am

    Not sure if I understand you correctly, but I would expect what you want to do is to schedule a call to ai() in your main GTK loop, so that your program checks if there is input on a regular base.

    If this is what you want you have two choices: scheduling the call periodically or schedule the call for when the program is idle (it is not doing anything else).

    Your code should look something like:

    gobject.idle_add(callback, ...)  #execute callback when idle
    gobject.timeout_add(interval, callback, ...)  #execute callback every interval millisecs
    

    The documentation should be here but presently there is a server error. Here are the relevant passages:

    The gobject.idle_add() function adds a function (specified by callback) to be called whenever there are no higher priority events pending to the default main loop. The function is given the default idle priority, gobject.PRIORITY_DEFAULT_IDLE. Additional arguments to pass to callback can be specified after callback. The idle priority can be specified as a keyword-value pair with the keyword "priority". If callback returns FALSE it is automatically removed from the list of event sources and will not be called again.

    The gobject.timeout_add() function sets a function (specified by callback) to be called at regular intervals (specified by interval, with the default priority, gobject.PRIORITY_DEFAULT. Additional arguments to pass to callback can be specified after callback. The idle priority may be specified as a keyword-value pair with the keyword "priority".

    A catch: you have your callbacks to return True if you want to keep them in the scheduler, failing to do so will make them execute only once.

    HTH!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an app that needs to detect a rotation gesture from the
Working on a project that parses a log of events, and then updates a
Has anyone managed to get the gesture recognition working in cocos-2d? I have read
i've got a class extended from simple on gesture and i'm working with the
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
Working on a project where a sequential set of methods must be run every
I'm working on an app that lets the user stack graphics on top of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.