ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxPython-users
wxPython-users
Re: [wxPython-users] Controlling threads
by Joe Brown other posts by this author
Mar 23 2003 8:30PM messages near this date
[wxPython-users] Re: Controlling threads | Re: [wxPython-users] Controlling threads
Threading is not really a wxPython specific topic.

However, in wxPython, additional threads should not interact directly 
with the gui, leave that job to the main thread! (where have I hard that 
before)

I have developed a threaded routine (because I'm experimenting, etc...) 
you can find the source in my project

http://recon.sourceforge.com

The module threaded_getstatus.py encapsulates 2 intertwined classes 
which deal with threads and signal events to wx.  It is also in the 
latest package release.  It may not be the most elegant example, but 
should help.  Since recon uses wxPython, it might help with wxPython 
interaction as well.

Heh, I used threads because of the default blocking operation of socket 
io...  argh...  I've since discovered the modules asyncore and select 
(various documentation reffered to poll() but that's burried in select 
module (which I was guessing was sql somehow), which I didn't find until 
after threads)  DOH, now I'm really off topic...  But I'm still 
learning!!! :)

-Joe

Davor Cengija wrote:

> I have a CLI python program for which I'm writing GUI. The program takes a 
> number of files and filters them. 
> 
> def OnStartButtonClick(self, event):
>         w = Worker(directory)
>         w.start()
> 
> I'd like to have the worker in a background thread so that GUI keeps 
> responding to events, and even more important, to have STOP button (which 
> will, I presume, put some kind of stopper object in some kind of queue, 
> which that background thread should check periodically.)
> 
> I'm very new to Python and I don't know how to implement that. The 
> following url explains some details but I wasn't able to incorporate it in 
> my program:
> 
> http://www.python.org/cgi-bin/moinmoin/ThreadProgramming
> 
> GUI still doesn't respond.
> 
> My Worker object is single-threaded (it takes one file after another). 
> Maybe I should rewrite it to something like 
> 
> for file in directoryList:
>         w = Worker(file)
>         w.start()
> 
> and basically have new Worker for each file.
> 
> Also, it is important that I should be able to stop the processing of a 
> single file at any given time, even in the middle of the process.
> 
> So, after all these requests, is there any good examples which I could use? 
> I already read the Threads example in the demo collection, but to be 
> honest, I really don't understand it :-)
> 
> Thanks in advance!
> 
> Regards,
> Davor
>   
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@[...].org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
Thread:
Davor Cengija
Davor Cengija
Joe Brown
Chuck Esterbrook

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved