up with PyGUI!
OKB (not okblacke)
brenNOSPAMbarn at NObrenSPAMbarn.net
Sun Sep 26 01:35:03 EDT 2004
Bengt Richter wrote:
> myFrame = (
> Frame(
> Sizer(
> CustButton(size= ... etc),
> CustButton(size= ... etc),
> Panel(
> Sizer(
> CustListBox(etc),
> CustListBox(etc),
> CustButton(etc),
> Text( etc )
> )
> )
> )
> )
> )
One problem with this is that it's not possible to define methods
on your widgets in this kind of structure.
>>If Python's syntax were more flexible, this could perhaps be done
>>in other ways -- I'm not saying I want that -- but as it is the
>>only real way to construct nested structures in Python is with
>>class definitions.
> You don't mean that ("...only real way...") as broadly as it
> sounds, do you?
Sorry, you're right. Obviously dictionaries and lists can be
nested. A key point, though, is the one I mentioned above: classes are
the only structure which allow you define nested structures with
arbitrary in-line code. The "in-line" proviso there may seem obtuse,
but I think it's important. For instance, if you define a button, you
should be able to define the event handler for a click on that button
right there, as part of writing the button code. Having to separate the
event-handling code out into a separate routine leads to
spaghettification, and also introduces a bunch of naming problems (you
need to have a consistent naming convention that links a widget to its
event handler).
(Also, just for the record: I know you can nest function
definitions in other functions, but this isn't useful here because
there's no way to access the nested function definition from outside the
enclosing function, whereas you can reference nested classes with normal
attribute access.)
--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
More information about the Python-list
mailing list