On May 14, 2010, at 3:29 PM, Neil Benn wrote:

> Hello,
> 
>         Thanks for the reply.  I'm puzzled here; I have a camera running in 
> the background grabbing frames from the camera; running some preprocessing on 
> the frames and then presenting the image on the window.  I'm also thinking of 
> recording some entries into a database and possibly making some network calls 
> when the app is runnign in an 'admin' mode.  I've programmed Java, .NET and 
> so on and the normal method I would use for this is to run the camera in one 
> thread in the background, then if I make remote calls or execute lengthy 
> databse queries from an event on the form (clicking a button or somethign 
> like that).  If I don't use threads for this then what would be the 'typical' 
> pyGTK method to handle both background tasks and executing lengthy events 
> from GUI events.
> 
>   I'm asking because I don't want to use a paradigm from another experience 
> which is not suitable to what I'm trying to do with python and gtk.  Thanks 
> for your help.

I've used threads in GTK programs without problems, as long as I never tried to 
run GTK code from within the thread. I started using pygtk back in the 0.6.x 
days and I don't think threads worked as well as they do now.  In any case, I 
always had my threads tell the main thread what needed to be done and it did 
the gtk work.  You can use timeouts and idle functions to do background work 
too, without having to fuss with threads.  Being an experienced threads 
programmer you are probably a step ahead though and maybe you should not shy 
away from using threads.

> 
> Cheers,
> 
> Neil
> 
> On 14 May 2010 19:09, Neil Muller <drnlmuller+...@gmail.com> wrote:
> On 14 May 2010 19:48, Neil Benn <neil.b...@ziath.com> wrote:
> > This starts up as you would expect, printing a and b to the screen as the
> > threading time time slicing allows. However once the PyGTK window has opened
> > - these threads just freeze.
> 
> To use threads, you need to enable pygtk's support for threads by
> calling gtk.gdk.threads_init().
> 
> http://unpythonic.blogspot.com/2007/08/using-threads-in-pygtk.html is
> a good brief overview of how to use pygtk and threads.
> 
> It's also worthwhile reading the gtk+ notes on threading at
> http://developer.gimp.org/api/2.0/gdk/gdk-Threads.html , especially if
> you're trying to write something portable between X11 and Windows.
> 
> I would, however, recommend looking at alternative options, such as
> multiprocessing, carefully first, before committing yourself to a
> threaded solution.
> 
> --
> Neil Muller
> drnlmul...@gmail.com
> 
> I've got a gmail account. Why haven't I become cool?
> _______________________________________________
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
> 
> 
> 
> -- 
> -- 
> 
> Neil Benn Msc
> Director
> Ziath Ltd
> Phone :+44 (0)7508 107942
> Website - http://www.ziath.com
> 
> IMPORTANT NOTICE:  This message, including any attached documents, is 
> intended only for the use of the individual or entity to which it is 
> addressed, and may contain information that is privileged, confidential and 
> exempt from disclosure under applicable law.  If the reader of this message 
> is not the intended recipient, or the employee or agent responsible for 
> delivering the message to the intended recipient, you are hereby notified 
> that any dissemination, distribution or copying of this communication is 
> strictly prohibited. If you have received this communication in error, please 
> notify Ziath Ltd immediately by email at i...@ziath.com. Thank you.
> _______________________________________________
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/

--
Steve McClure
smccl...@racemi.com

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

Reply via email to