Threads and GUI question

Alessandro Bottoni alessandro.bottoni at infinito.it
Tue Oct 22 03:00:32 EDT 2002


Alle 21:23, lunedì 21 ottobre 2002, Pekka Niiranen ha scritto:
> Hi,
>
> I am using wxWindows in win2000 to start a loop that writes to a COM -port:
>
> runOK = 1
> while runOK != -1:
>          -- write data to COM -port--
>
> My original idea was to have a Stop -selection in menubar,
> that would set runOK = -1 and cause the while loop above to stop.
>
> The problem is that menubar does not response while
> the while -loop is running.
>
> Should I use threads or am I missing some simple trick ?
> If using threads, how many do I need ? Only two ?
>
> -pekka-

I think that your original idea does not work just because the while loop 
does not give the GUI any time (that is: any CPU cicle) for listening to the 
user's actions. Just add a sleep(n) (where n are seconds) inside the while 
loop and it should work fine. Have a look at the wxWindows doc for the 
details and the correct sintax. Look for "sleep", "process control" or 
"process management".

BTW: do you know that wxWindows and wxPython have their own support mailing 
lists? Have a look at their web sites for the addresses to contact. Most 
likely, they can help you much more than us.

---------------------
Alessandro Bottoni





More information about the Python-list mailing list