views:

78

answers:

1

Hi everyone, I'm newbie in python and I'm trying to use pyinotify with a GUI interface using pygtk. I have two classes, my gtk class which doesn't do much, only displays stuff, and a class that handles the monitoring.

When I run them separately they do their work but when I try to load the gtk class from the other one, it only runs the gtk class, the monitor class only runs when I exit the GUI. If I comment the last line the monitor runs fine. I think the "myGTK.main" is blocking the whole process. Is there anything I can do?

pyinotify.ProcessEvent.__init__(self)
self.notifier = pyinotify.ThreadedNotifier(self.watch_manager, self)    
self.watch_manager.add_watch('/test', pyinotify.IN_CREATE, rec=True)
self.notifier.start()
self.myGTK.main()

Thanks.

+2  A: 

Per the comments, the solution appears to be to add

gobject.threads_init()

near the top of the script. This, and other useful information about using threads with pygtk can be found in this faq.

unutbu