[pygtk] PyGTK GUI update without signals from GUI
Andrew Lapidas
alapidas at student.umass.edu
Tue Apr 15 23:35:57 WST 2008
Stephen, John:
Thank you for your replies so far. I am still trying to figure out
the best way to do this. To be more descriptive, I have a small
program (~400 lines) that controls a digital camera and does some
image processing in a scripting fashion. This program will run
infinitely. There are about 7 points in this program where I would
like to update my GUI. If I implement threading, I will spawn just
one thread for this program. I still am unsure of the best way to do
this.
Also, what is the GObject module and how does it differ from the pygtk module?
Thanks,
Andy
On Mon, Apr 14, 2008 at 7:04 PM, Stephen George
<steve_geo at optusnet.com.au> wrote:
> Hi Andrew,
>
>
> Andrew Lapidas wrote:
>
> > I am currently having a problem updating a GUI.
> >
> > I am using PyGTK and Glade to design an interface for a project. This
> > interface contains no buttons, just images, labels, and a progress
> > bar. The code for the project is small, and it basically does some
> > things independent of the GUI in an infinite loop.
> >
> Regarding 'does some things'
> Is this constant processing or periodic checking.
> Periodic checking would be easier to do with timers
>
> http://www.pygtk.org/pygtk2tutorial/ch-TimeoutsIOAndIdleFunctions.html#sec-Timeouts
>
> also have a read of
> http://www.pygtk.org/pygtk2tutorial/sec-IdleFunctions.html
>
>
>
>
> > I need the project
> > code to update the GUI intermittently. I have found, though, that
> > generally it seems that the gtk.main loop is looking for signals from
> > the GUI and I cannot figure out how to give it signals from another
> > application.
> >
> Do you really want a separate application to talk to your GUI, means you
> will have to look at some sort of inter process communication.
> sockets, or something more elaborate pyro http://pyro.sourceforge.net/
> I'm sure there is many others.
>
>
>
> > I have thought spawning a new thread from the __init__
> > in the GUI and somehow having it send signals to gtk.main, but I do
> > not know if this will work.
> >
> >
> Yes, .. you can set up your own 'signals' but I found it's not well
> documented in pyGTK manual
> http://www.pygtk.org/pygtk2tutorial/ch-AdvancedEventAndSignalHandling.html
>
> Instead I referred to gobject documentation from here
>
> http://www.sicem.biz/personal/lgs/docs/gobject-python/docs/gobject-python/gobject-tutorial.html
> look at section 'creating your own signals'
> but I'm sure there is many other gobject documentation around on net.
>
> When emiting from a thread for any signal whose handler updates the GUI.,
> need to do it safely by adding the emit to the idle loop.
> gobject.idle_add(self.emit, "cntlrFinaliseConnection")
>
> Have a read, try an implementation, .. if you then get problems ask more
> questions
>
> Steve
>
>
>
>
>
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
--
Andrew Lapidas
email / alapidas at student.umass.edu
phone / 774.279.4740
More information about the pygtk
mailing list