How to write GUI and event separately in wxPython??

Steve Holden steve at holdenweb.com
Mon Jul 30 06:32:55 EDT 2007


Marc 'BlackJack' Rintsch wrote:
> On Sun, 29 Jul 2007 23:34:14 -0700, Jia Lu wrote:
> 
>>  I am making an application with wxpython.
>>  But I got a problem when I want to change the display string
>> according to process status.
>>
>>  I passed the frame to the processing function and use the
>> frame.txtobj to change displaying strings.
>>
>>  I found it is a bad method to do that.
>>  Can any one tell me how to do that usually?
>> ( How to separate GUI and Control code? )
> 
> One possibility here is to give a callback function into the worker
> function that gets called while the function does it's work.  Simple
> example:
> 
> def do_work(arguments, callback=lambda msg: None):
>     callback('Start processing.')
>     for percent in xrange(0, 101):
>         callback('finished %d%%...' % percent)
>     callback('Done.')
> 
 >>> [x for x in xrange(0, 101)] == [y for y in xrange(101)]
True
 >>>

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list