Doug Quale <[EMAIL PROTECTED]> wrote: > > There's one other possibility that I don't really understand, but I'd > like to look into it. PEAK is a Python framework for enterprise > applications (http://peak.telecommunity.com/). PEAK implements many > fascinating ideas. In particular its domain model module does > something very interesting with metaclasses and nested classes. > Applied to our area of interest it might look something like this: > > class MyApp(GWidget): > > class name(Widget.TextEntry): > > max_length = 40 > > def validate(self, ...): > # some validation code here > > # other properties for the name TextEntry widget > > class age(Widget.SpinButton): > > step = 1 > digits = 0 > lower = 1 > upper = 120 > > ... > > PEAK uses metaclasses to do extensive processing of the nested classes > so that users of instances of the object see regular looking > attributes with the same names as the nested classes. This permits > associating a lot of metadata with each attribute without using an > absurd number of keyword parameters in the descriptor constructors. > Compare this to: > > class MyApp(GWidget): > > def validate_name(self, ...): > ... > > name = Widget.TextEntry('name', max_length=40, > validate_fn=validate_name, > ...) > > age = Widget.SpinButton('age', step=1, digits=0, > lower=1, upper=120, ...) > >
Well, writing widget classes for each GWidget class is certainly painful for the programmers. All he can do concisely is to write lambda functions as wrappers. But surely I'm looking for easy usage for GTK+ widgets. Instead of this txt = button.get_text() button.set_text(txt) we can make use of 'property' to do this .. txt = button.text button.text = txt Another important thing is writting proxy widgets doesn't help if UI is loaded from glade XML. so putting it in a line, is this discussion all about making the pygtk api much better and easy to use some which includes the one given above ? I have the implementation of StringValidator class that is used in validation of changeable data in widgets. Look for the python module in this snapshot http://cs.annauniv.edu/~rsridhar/pub/pythondevelop/snapshots/ (That was a quick hack, though) -- Sridhar - http://www.cs.annauniv.edu/~rsridhar Blog: http://www.livejournal.com/users/sridharinfinity _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
