Pygtk, libglade

Graham Ashton gashton at cmedltd.com
Wed Dec 10 04:32:45 EST 2003


On Tue, 09 Dec 2003 19:09:38 -0500, Vams wrote:

> Problem:
> ---------- gtk.main() -------------
> The GUI won't show up w/o calling this function.  And if I do call this 
> function, the control of my program will stay in the mainloop until it 
> exists (GUI closes).  This stops the daemon from doing what it normally 
> does.
> 
> So, what do I need to do?  Should I have the gtk.main() in its own 
> thread or something?  Or can I somehow extend the gtk.main() so that it 
> does my program's tasks while keeping an eye on the GUI?

You could split it into two programs; the daemon and the GUI. Then use
gtk.timeout_add() to specify a call back function that the GUI can run to
query the status of the daemon.

It'd certainly be cleaner than threads. An alternative would be to use
some file based IPC between the GUI and the daemon and use
gtk.input_add() to get GTK to monitor the file handle for changes and run
a function whenever it becomes readable.

> Any help would be appreciated.

Don't go near threads unless the above two approaches don't do what you
want!

-- Graham




More information about the Python-list mailing list