471,578 Members | 1,306 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,578 software developers and data experts.

Pygtk, libglade

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
2 2737
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
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.

Similar topics

1 post views Thread by Will Ware | last post: by
reply views Thread by zinc | last post: by
4 posts views Thread by j_mckitrick | last post: by
5 posts views Thread by Egbert Bouwman | last post: by
5 posts views Thread by Viktor | last post: by
reply views Thread by Doug | last post: by
1 post views Thread by krishnakant Mane | last post: by
reply views Thread by Michael Palmer | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.