[wxPython-users] using lambda to pass args to event function

Christopher Barker Chris.Barker at noaa.gov
Tue Nov 21 16:29:31 PST 2006


TiNo wrote:
> I googled around for ways to organise my code and only found this:
> http://wiki.wxpython.org/index.cgi/OrganizingYourCode
> After this example I designed:
> - a main file: contains App class. In the app class I some instances
> of fundamental classes (MainFrame, Notebook), and a 'controller', an
> instance of the Event class.
> Because I can 'reach' into both the controller and the gui classes, I
> do most Binds here.
> - a gui file: containing several classes like the MainFrame, the
> toolbar, dialogs, notebook pages, etc. I try to keep all events out of
> here, but sometimes that becomes to much of a hassle.

Are you using wxGlade? in that case, keeping the GUI code separate makes 
sense, but I'm not sure it does otherwise. That's one reason I haven't 
used GUI-builders...

> - the event file(class): containing all methods that are executed when
> a user does something.

I think keeping all the "Real" functionality separate from the GUI is 
good, but you don't' need to bind the events there. The actual events 
can get bound in with the GUI classes, and the handlers then make calls 
into the the module that does the real work (The Model in MVP or MVC).

> This works so far. But I begin to see its limitations. For example,
> the OnSize function for a ListCtrl. It would be way awkward to have
> that method in the events class, and bind it in in the App class, and
> why would I.

exactly -- SIZE event handlers are a strictly gui function -- keep them 
with that code.

> (or other websites for that matter)

This is a good one (and points you to others)

http://wiki.wxpython.org/index.cgi/ModelViewPresenter


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list