Im Rahmen meiner ersten Ausflüge in die GUI-Programmierung mittels PyGtk möchte ich mir gern mal eure Meinung zu folgenden Code-Schnipsel einholen:
Code: Alles auswählen
class LabelledBox(Gtk.Frame):
"""
Composition class to provide a widget similar to Gtk.Box but with an additionally labelled frame.
This class delegates all instance attribute fetches to the embedded Gtk.Box instance.
"""
__gproperties__ = {}
def __init__(self, label, **kargs):
Gtk.Frame.__init__(self, label=label)
# To avoid recursive loops during instance attribute fetch
# we add the instance attributes directly into self.__dict__
self.__dict__['_content_box'] = Gtk.Box(**kargs)
self.__dict__['_content_box'].set_border_width(6)
self.add(self.__dict__['_content_box'])
def __getattr__(self, attr):
return getattr(self._content_box, attr)
def __setattr__(self, attr, value):
return setattr(self._content_box, attr, value)
def do_get_property(self, prop):
return getattr(self, prop.name)
def do_set_property(self, prop, value):
setattr(self, prop.name, value)
Schöne Grüße