How to write GUI and event separately in wxPython??

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Jul 30 04:09:54 EDT 2007


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.')

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list