This is how I would write it.
import dabo
dabo.ui.loadUI("wx")
class TestForm(dabo.ui.dForm):
def afterInit(self):
self.Sizer = dabo.ui.dSizer("v")
self.pnl = dabo.ui.dPanel(self)
self.Sizer.append1x(self.pnl)
self.pnl.Sizer = mainSz = dabo.ui.dSizer("v")
lblSz = dabo.ui.dSizer("h", DefaultSpacing=5, DefaultBorder=20,
DefaultBorderLeft=True, DefaultBorderRight=True)
lblSz.append(dabo.ui.dLabel(self.pnl, Alignment = "Left",
Caption= "This is a test.", RegID="lblMsg"))
btnSz = dabo.ui.dSizer("h")
btnSz.append(dabo.ui.dButton(pnl, Caption = "OK",
RegID="btnOk"), "center")
mainSz.append(lblSz, "expand", 1)
mainSz.append(btnSz, "expand", 0)
def initProperties(self):
self.Caption = "TestForm"
self.Size = (200, 400)
self.Position = (300, 200)
if __name__ == "__main__":
app = dabo.dApp()
app.MainFormClass = TestForm
app.start()
Note the use of RegID's. You need them so that an event function like
onHit_btnOk will be linked to the hit of the btnOk widget. You can
get away with not using them in the form, but if you break your GUIs
up into panel classes and such you really need to start using it.
Note that it is also a good idea and often necessary to add the main
panel to the form sizer.
Also, all properties except the Sizer property should be initialized
in initProperties. It won't hurt for them to be in afterInit, but it
good coding practice to move them.
Last, if you want to layout your form, you only need to call
self.layout() in the form class. I removed it from the above code
because the layout would change the size of the form which you had set
earlier...
Hope this helps.
Cheers,
Nate L.
On 3/2/07, Paul McNett <[EMAIL PROTECTED]> wrote:
> Kelie wrote:
> > hello,
> >
> > what did i do wrong in the code below? i wanted to show a label, a
> > button on a form, but they're not shown when form is displayed. i
> > guess the error is in the sizers.
>
> You need to add the pnl to the Form's sizer:
> self.Sizer.append1x(pnl)
>
> > another question: does every dForm have the standard menu "File",
> > "Edit", "View" and "Help"? how do i modify the menu items? or what if
> > i don't want menu for very simple form?
>
> By default, every form gets that menu. It is defined in
> ui/uiwx/dBaseMenuBar, and you can modify it using calls like
> appendMenu(), appendItem(), removeItem(), etc. Or, you can define your
> own and drop it in using:
>
> class MyForm(dabo.ui.dForm):
> def initProperties(self):
> self.MenuBar = MyMenuBar()
>
> Or if you want no menubar:
>
> self.MenuBar = None
>
>
>
> _______________________________________________
> Post Messages to: [email protected]
> Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
>
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users