wxPython syntax

David Fraser davidf at sjsoft.com
Tue Jun 29 09:59:23 CEST 2004

OKB (not okblacke) wrote:
> David Fraser wrote:
>>MenuDeclaration = """ ... """ # put the above string in here...
>>MenuResource = wxResourceParser.Parse(MenuDeclaration)
>>class FileMenu(MenuResource):
>>     def OnAbout(self, event):
>>         # put the code here
>>     def OnExit(self, event):
>>         # put the code here
>     	This is a cool idea.  I like the looks of it.  One worry I have, 
> though, is that with the code outside the hierarchical definition 
> there'll still be confusion about the organization.  What if you have a 
> menu bar as well as some other widgets, or submenus?  Also, what about 
> things like listboxes, where you want the list elements to be determined 
> programmatically?  Various interrelationships might exist between the 
> GUI's appearance and its content, which could be difficult to express if 
> the layout were being specified with some static text.  I'm not sure how 
> best to handle this, but I think it's something to think about.

The idea of this approach is that you use the resource string to define 
the simple stuff and then do the rest in code. For example, define a 
list box but no elements, than add them in the initializer. Because the 
Resource is used as a base class for the class you are declaring, you 
can call its initializer from the derived classes initializer, and then 
make any changes that are desired (including adding custom widgets or 
even doing fancy things with sizers).
One of the main things that would need to be addressed is how sizers and 
layout could be defined using this approach


More information about the Python-list mailing list