Commits

Henning Schröder  committed 3c2f244

tried adding simple property setters

  • Participants
  • Parent commits 573b43e

Comments (0)

Files changed (3)

 
 
 
-    def __init__(self, parent=None):
+    def __init__(self, parent=None, **kwargs):
         TObject._object_instances.add(self)
         self._children = set()
         self._parent = None
     
         if parent:
             self.setParent(parent)        
+            
+        for key, value in kwargs.items():
+            setter = getattr(self, "set%s" % (key[0].upper() + key[1:]), None)
+            if not setter:
+                raise TypeError("Invalid keyword argument %r" % key)
+            setter(value)
+    
     
             
 
     
     
     
-    
-    
-    
 
 app = TApplication()
 app.desktop().show()
-win = TWidget()
+win = TWidget(size=(10,10))
 win.move(5,5)
-win.resize(60,15)
+#win.resize(60,15)
 
 
 c = TCheckBox(win)
 class TWidget(TObject):
 
     
-    def __init__(self, parent=None):
-        super(TWidget, self).__init__(parent)
+    def __init__(self, parent=None, **kwargs):
+        super(TWidget, self).__init__(parent, **kwargs)
         self._focus_policy = TFocusPolicy.TabFocus
         self._update_geom(TPoint(0,0), self.sizeHint(), silent=True)
         self._visible = True
 class TLabel(TWidget, AbstractTextWidgetMixin):
 
     
-    def __init__(self, parent=None, text=""):
-        AbstractTextWidgetMixin.__init__(self, text)
-        TWidget.__init__(self, parent)
+    def __init__(self, parent=None, **kwargs):
+        AbstractTextWidgetMixin.__init__(self)
+        TWidget.__init__(self, parent, **kwargs)
         self.setFocusPolicy(TFocusPolicy.NoFocus)
 
 
     clicked = Signal()
     
     
-    def __init__(self, parent=None, text="", checked=False, checkable=False):
+    def __init__(self, parent=None, text="", checked=False, checkable=False, **kwargs):
         AbstractTextWidgetMixin.__init__(self, text)
         self._checked = checked
         self._checkable = checkable
-        TWidget.__init__(self, parent)
+        TWidget.__init__(self, parent, **kwargs)
 
         
     def setCheckable(self, flag):
     stateChanged = Signal()
     
     
-    def __init__(self, parent):
-        super(TCheckBox, self).__init__(parent, checkable=True)
+    def __init__(self, parent, **kwargs):
+        super(TCheckBox, self).__init__(parent, checkable=True, **kwargs)
         
         
     def setChecked(self, flag):