PDA

View Full Version : Tutorial on threading in pyGTK



Shazzner
October 2nd, 2010, 06:03 AM
I'm creating an app with Quickly that uses OpenCV to detect faces via the OpenCv library which has to poll the camera constantly while GTK is doing it's thing so, I assume, it needs to be on a separate thread.

The final app should act very much like Cheese does, only using the OpenCv framework.

Threading is always a bit confusing to setup and I'm pretty new to python, so any links or info to go about doing this would be great. Thanks!

StephenF
October 2nd, 2010, 07:15 PM
You can add callbacks to the event loop with gobject.timeout_add. No need for a separate thread unless one of your GTK callbacks is taking too long and even then they can sometimes be broken up.

diesch
October 3rd, 2010, 01:04 AM
Have a look at the section "20. The GTK Mainloop and Threading" of the PyGTK FAQ (http://faq.pygtk.org/index.py?req=index)

Shazzner
October 3rd, 2010, 04:31 AM
Wow, that was much simpler than I thought it was going to be. Thanks for the help!