up with PyGUI!

OKB (not okblacke) brenNOSPAMbarn at NObrenSPAMbarn.net
Sat Sep 25 00:49:40 EDT 2004


Ed Leafe wrote:

>> class MainFrame(FrameDescription):
>>
>>     class b1(ButtonDescription):
>>       size = (40, 40)
>>       text = "b1"
>>
>> ... where FrameDescription and ButtonDescription are both derived
>> from a base Container class. When constructed, the MainFrame will
>> contain an **instance** called b1 from the class b1 (that's right,
>> the same name; the temporary class definition is gone). The
>> metaclass creation engine also respects the order of the
>> declaration. 
> 
>      How is this more powerful/flexible/robust than something like:
> 
> class MainForm(dabo.ui.dForm):
>      def __init__(self, parent=None):
>           self.addObject(ButtonDescription, "b1")
>           self.b1.Size = (40,40)
>           self.b1.Caption = "b1"
> 
> ...which is the standard syntax in Dabo for adding objects to a
> form (frame)?

    	I would say that the former is a great deal more readable.  In 
particular, this is one case where having to use an explicit "self" 
really hurts.  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.

    	In the same vein as what Carlos Ribeiro said in another post: it's 
my opinion that defining the GUI layout is a fundamentally declarative 
task, and forcing the programmer to perform it in a procedural fashion 
is working against the grain of the problem.

-- 
--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