473,412 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 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 2816
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Will Ware | last post by:
In July there was a thread about problems on Red Hat 9 with PyGTK not playing nice with Glade. I was tinkering with this a little bit tonight, starting with the code I found in this article:...
0
by: zinc | last post by:
Hi Pythoneers, Im interested in trying some gui programming with the GTK2 toolkit. I found this brief article,(http://www.linuxjournal.com/article.php?sid=6586), that speaks about utilising...
4
by: j_mckitrick | last post by:
Hi all. Here is a tiny container for one of each combo box, along with the glade file. Just 2 widgets, so hopefully not too large. How the heck do I get the selection from the ComboBox, as...
5
by: Egbert Bouwman | last post by:
As a newby to PyGTK I already have produced some gui's I like, but I have difficulties in finding out what method or other instrument I need for doing various things. I have not yet found the...
5
by: Viktor | last post by:
Did anybody managed to "pack", a program that uses pygtk with pyexe? The best result I got was: Pango-ERROR **: file shape.c: line 75 (pango_shape): assertion faled: (glyphs->num_glyphs > 0)...
25
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK...
0
by: Doug | last post by:
I am having some fun running a program called pygps. This uses libglade and runs fine on my very old Redhat 7.? system running Python 1.5.2. I have not needed to make any changes to the import...
1
by: krishnakant Mane | last post by:
hello, I will be writing some code in PyGTK to run on linux. but I want to know if there are any installers or distutils available for PyGTK on windows? I have heard that installing gimp or even...
0
by: Michael Palmer | last post by:
On Sep 16, 12:30 pm, binaryjesus <coolman.gu...@gmail.comwrote: I haven't tried it myself, but I came across a blog post the other day that describes a way of building windows installers for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.