472,959 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,959 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 2797
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.