up with PyGUI!
OKB (not okblacke)
brenNOSPAMbarn at NObrenSPAMbarn.net
Sat Sep 25 21:47:59 CEST 2004
Ed Leafe wrote:
> There is also nothing to prevent you from writing that button as a
> class definition (although I have a personal dislike of a 'class'
> being used for an instance). Something like:
> class MainForm(dabo.ui.dForm):
> def __init__(self, parent=None):
> class btn1(ButtonDescription):
> Size = (40, 40)
> Caption = "b1"
> self.addObject(btn1, "b1")
> To my eye, that's a lot uglier than writing it as it is:
> coding. Dressing it up as a class in order to save typing 'self'
> isn't justified, IMO.
Well, I see what you mean, but conversely, even in the example you
gave above, it seems to me that the "def __init__" is (or should be)
superfluous. The very fact that you are defining a button inside a
panel clearly indicates that you want the button to be added to the
panel. Restating this information repeatedly with an __init__ and self
references and explicit "add" methods is cumbersome.
Admittedly, the need to use the word "class" is unfortunate, but I
prefer to simply ignore that little keyword in the definition. That is,
what about this:
caption = "One"
caption = "Two"
I think the indentation here clearly indicates the intended nesting
structure of the GUI layout. Python requires me to use the word "class"
before each component to get a valid syntactical construct, but I find
it much easier to put single keyword ahead of each GUI object definition
than to wade through a series of method definitions to extract
information about how the components are structured inside one another.
--OKB (not okblacke)
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
More information about the Python-list