monitor mouse coordinates in real-time

J

Jabba Laci

Hi,

I wrote a simple GUI with pygtk to monitor mouse coordinates in
real-time. It works but when I close the application, the thread
doesn't stop and I can't figure out how to terminate it. Here is the
current source: https://gist.github.com/1144708 (83 lines).

Could you please help me out how to close the application correctly?

Thanks,

Laszlo
 
T

TheSaint

Jabba said:
Could you please help me out how to close the application correctly?
I think you should put a flag into the code, which the parent might modify
it, so it will tell the child process to quit.
Then the flag should need to be read periodically to know whether is time to
quit.
 
J

Jabba Laci

I'm trying something similar. In the thread there is a variable which
is modified by the parent. However, the thread doesn't quit the
infinite loop. If someone could provide a patch, that'd be really
useful.

Thanks,

Laszlo
 
J

Jabba Laci

Hi,

Thanks, the problem got solved. The updated version can be found at
https://gist.github.com/1144708 in a comment below the original post.
Solution:

self.connect("destroy", self.quit)

def quit(self, widget):
self.mouseThread.kill()
gtk.main_quit()

It was not evident that quit() must be passed the argument "widget" too.

Thanks,

Laszlo


Check that the app.quit method registered with atexit is called.  E.g.
on Windows, that may not be the case.

/JeAN


I'm trying something similar. In the thread there is a variable which
is modified by the parent. However, the thread doesn't quit the
infinite loop. If someone could provide a patch, that'd be really
useful.

Thanks,

Laszlo


Jabba Laci wrote:
Could you please help me out how to close the application correctly?
I think you should put a flag into the code, which the parent might modify
it, so it will tell the child process to quit.
Then the flag should need to be read periodically to know whether is time to
quit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top