Thank you!
I saw dGridSizer too late, when I implemented my Panel subclass for  
proper alignment:

class Panel(dabo.ui.dPanel):
     """
     Descendant of `dPanel` with simple layout functions.

     You might want to access:
     :Sizer: main horizontal sizer
     :VS: main vertical sizer
     """
     def afterInit(self):
         super(Panel, self).afterInit()
         self.Sizer = dabo.ui.dSizer('horizontal')
         self.VS = dabo.ui.dSizer('vertical')
         self.VS.DefaultBorder = 5
         self.VS.DefaultSpacing = 5
         self.Sizer.append(self.VS, proportion=1, layout='normal',  
alignment='top')
         self.bindEvent(events.Save, self.onSave)

     def changeMainSizer(self, **kwargs):
         """
         Allow for changing layout properties of main vertical sizer  
(`self.VS`).

         Parameters: see dSizer.append.

         Defaults:
         :proportion: 1
         :layout: normal
         :alignment: top
         """
         defaults = {
             'proportion': 1,
             'layout': 'normal',
             'alignment': 'top',
         }
         for k in defaults:
             if not k in kwargs:
                 kwargs[k] = defaults[k]
         self.Sizer.remove(self.VS)
         self.Sizer.append(self.VS, **kwargs)

     def addSpacer(self, proportion=0, size=5):
         """
         Add a spacer to the main vertical sizer
         """
         self.VS.appendSpacer(size, proportion=proportion)

     def addVertical(self, object, **kwargs):
         """
         Add object to main vertical sizer.
         Shortcut to VS.append (with kwargs) and VS.append1x (without  
kwargs).
         """
         if not kwargs:
             return self.VS.append1x(object)
         else:
             return self.VS.append(object, **kwargs)

     def addLine(self, widget, **kwargs):
         """
         Add a line with label and widget to the main vertical sizer,  
return widget.

         Required kwargs:
         :Caption: Caption of the label
         """
         hs = dabo.ui.dSizer('horizontal')
         lb = dabo.ui.dLabel(self, Caption=kwargs['Caption'])
         hs.append(lb, proportion=4)
         hs.append(widget, proportion=10)
         hs.appendSpacer(5, proportion=1)
         self.VS.append1x(hs)
         return widget

     def addLabelLine(self, *args, **kwargs):
         """
         Add a line with just a label, return label widget.

         :Keywords:
             Caption : str
                 Caption of the label (also accepted as first argument)
         Other args and kwargs are ignored.
         """
         if args and not 'Caption' in kwargs:
             kwargs['Caption'] = args[0]
         lb = dabo.ui.dLabel(self, Caption=kwargs['Caption'])
         self.VS.append1x(lb)
         return lb

     def addButtonLine(self, *args, **kwargs):
         """
         Add a line with label and button, return the widget

         :Keywords:
           Caption : str
             Caption of the label
           Text : str
             Caption of the button
         ... and everything you need for the button
         """
         cbkwargs = kwargs.copy()
         if 'Text' in kwargs:
             cbcaption = kwargs['Text']
             del kwargs['Text']
             del cbkwargs['Text']
             cbkwargs['Caption'] = cbcaption
         return self.addLine(dabo.ui.dButton(self, **cbkwargs),  
**kwargs)

     def addInputLine(self, **kwargs):
         """
         Add a line with label and `dTextBox` to the main vertical  
sizer, return the widget.

         Required kwargs:
         :Caption: Caption of the label
         ... and everything you need for the dTextBox
         """
         return self.addLine(dabo.ui.dTextBox(self, **kwargs), **kwargs)

     def addSecretInputLine(self, **kwargs):
         """
         Add a line with label and "PasswordEntry" `dTextBox` to the  
main vertical sizer, return the widget.

         Required kwargs:
         :Caption: Caption of the label
         ... and everything you need for the dTextBox
         """
         kwargs['PasswordEntry'] = True
         return self.addLine(dabo.ui.dTextBox(self, **kwargs), **kwargs)

     def addCheckboxLine(self, **kwargs):
         """
         Add a line with label and `dCheckBox`, return the widget

         :Keywords:
           Caption : str
             Caption of the label
           Text : str
             Caption of the checkbox
         ... and everything you need for the dCheckBox
         """
         cbkwargs = kwargs.copy()
         if 'Text' in kwargs:
             cbcaption = kwargs['Text']
             del kwargs['Text']
             del cbkwargs['Text']
             cbkwargs['Caption'] = cbcaption
         return self.addLine(dabo.ui.dCheckBox(self, **cbkwargs),  
**kwargs)

     def addFileInputLine(self, **kwargs):
         """
         Add a line with label, `FilepathInput` and Browse button to  
the main vertical sizer, return the widget.

         :Keywords:
             Caption : str
                 Caption of the label (required)
         ... and everything you need for the TextBox
         """
         hs = dabo.ui.dSizer('horizontal')
         lb = dabo.ui.dLabel(self, Caption=kwargs['Caption'])
         finput = FilepathInput(self, **kwargs)
         btn = dabo.ui.dButton(self, Caption=_(u'Browse'))
         btn.bindEvent(dEvents.Hit, finput.onBrowse)
         hs.append(lb, proportion=4)
         hs.append(finput, proportion=8)
         hs.append(btn, proportion=2)
         hs.appendSpacer(5, proportion=1)
         self.VS.append1x(hs)
         return finput


In my version there are some more additional methods addSomething for  
every commonly used widget and some of my own (like FilepathInput with  
a getFolder/getFile dialog and some validation) as shortcuts to  
self.addLine(someWidget, {}).


Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net
https://www.cacert.org (I'm an assurer)





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to