up with PyGUI!
Ed Leafe
ed at leafe.com
Sat Sep 25 14:20:07 EDT 2004
On Sep 25, 2004, at 4:49 AM, OKB (not okblacke) wrote:
> You've already had to retype "self.b1" twice just to
> specify the size and caption. What if you wanted to specify a color?
> A
> background color? To say nothing of an event handler.
Obviously, if things were that complex, you could set a reference to
the button and use that reference instead of the 'self' construct.
class MainForm(dabo.ui.dForm):
def __init__(self, parent=None):
self.addObject(ButtonDescription, "b1")
btn = self.b1
btn.Size = (40,40)
btn.Caption = "b1"
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: instance
coding. Dressing it up as a class in order to save typing 'self' isn't
justified, IMO.
___/
/
__/
/
____/
Ed Leafe
http://leafe.com/
http://dabodev.com/
More information about the Python-list
mailing list