[pygtk] Gtk programming technique question...

2 views
Skip to first unread message

GSO

unread,
Feb 13, 2011, 7:32:47 PM2/13/11
to py...@daa.com.au
Quick coding problem if I may.

I am displaying jpegs from CCTV cameras in a HBox, but need some way
to refresh the images in that box. I need to show the main window,
but then refresh the images in that window. How would I do this given
after opening the window the programs then waits at the gtk.Main event
loop.

Have tried with the multiprocessing module, but any new threads don't
seem to be able to access the memory of the main window to be able to
refresh the images.

RHEL6, pygtk2 v2.16, Gtk v2.18.9

Thanks in advance,
_______________________________________________
pygtk mailing list py...@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

jbo...@amathaine.com

unread,
Feb 13, 2011, 8:19:33 PM2/13/11
to py...@daa.com.au
I'd suggest using either an idle or timeout callback. That should
solve your immediate issues.

http://www.pygtk.org/pygtktutorial/ch-timeouts.html

If you're working with multimedia (in particular if it's likely you'll
want to provide live feeds in future) I'd suggest having a look at
gstreamer, which integrates nicely into the GTK main loop.

GSO

unread,
Feb 13, 2011, 10:01:37 PM2/13/11
to jbo...@amathaine.com, py...@daa.com.au
OK, cheers, got that. Would never have guessed that that was lurking
down there in the darkest depths of gobject. Will have to study that
tutorial properly.

I'm creating a PyGtk desktop client for motion
http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome - a CCTV
program. The GUIs available all require Apache and MySQL - which is
overkill if you don't need the industrial level features, it's better
keeping things simple as well for security reasons.

I haven't ever created or managed an opensource project before (or
used Python or Gtk for that matter, they are both pretty cool though).
But I am at this point I think now I have that working heading over
to Google code. The project will be called gmotion.

Adam Tauno Williams

unread,
Feb 14, 2011, 5:44:58 AM2/14/11
to py...@daa.com.au
On Mon, 2011-02-14 at 00:32 +0000, GSO wrote:
> Quick coding problem if I may.
> I am displaying jpegs from CCTV cameras in a HBox, but need some way
> to refresh the images in that box. I need to show the main window,
> but then refresh the images in that window. How would I do this given
> after opening the window the programs then waits at the gtk.Main event
> loop.
> Have tried with the multiprocessing module, but any new threads don't
> seem to be able to access the memory of the main window to be able to
> refresh the images.

1. Start a thread that runs a Manager
<http://docs.python.org/library/multiprocessing.html#using-a-remote-manager> for an object that pushes events into the main loop via an idle handler.
2. Start worker processes for each camera that connect to the manager in
the main process and send updates via the manager.

Patrick Sabin

unread,
Feb 14, 2011, 8:13:02 AM2/14/11
to py...@daa.com.au
Don't know, how you get the images. However, if I have to do some gui
and some other I/O, I usually use twisted, where you don't have the
troubles of synchronizing your data for different threads/processes. You
can integrate the twisted reactor into the gtk main loop.
http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html#auto11

- Patrick

Reply all
Reply to author
Forward
0 new messages