By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,505 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,505 IT Pros & Developers. It's quick & easy.

Pygtk, libglade

P: n/a
Hi everyone,
I got a little problem that I hope someone can help me out w/ or
atleast point me in the right direction.

Situation:
- I have a python program that continuously runs and does some tasks
automatically on a daily basis.
- Now, I want to create a gtk frontend that displays its status and
provides an exit button so I don't need to keep sending the daemon a
kill signal.

What I wanted to do:
- make a class that creates the GUI using libglade and pygtk.
- create the GUI using the outside class and make a function within my
main program that continuously updates the GUI instance when called on.

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?

Any help would be appreciated.

Thank you,
Vams
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Vams <gt*****@prism.gatech.edu> writes:

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?


I don't know if running mainloop in separate thread is a good idea. I
suggest running your main program in a separate thread.
(See the faq on threading:
http://www.async.com.br/faq/pygtk/index.py?req=index)

An alternative is to use gtk.timeout_add() to call the main program at
regular intervals.

--
Fredrik Arnerup <e9*****@e.kth.se>
Jul 18 '05 #2

P: n/a
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
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.