On Mar 2, 2007, at 10:03 PM, Kelie wrote:
>> 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.
>
> wow, this is a nice trick. it eliminates the need to specifically
> bind the
> event.
Even cooler is passing the binding to the constructor. You can
create a button like this:
btn = dabo.ui.dButton(self, Caption="Wow", OnHit=self.onWowButton)
...and this will automatically bind the Hit event to the
self.onWowButton method.
> why isn't the OK button centered horizontally? in this line
> btnSz.append(dabo.ui.dButton(self.pnl, Caption = "OK", RegID="btnOk"),
> halign = "center")
The button is the only thing in that sizer. Then that button sizer
is added to the mainSz, but it isn't centered there.
You could simplify things even more. I've updated Nate's code so
that it works the way you expect. The code follows my sig.
> also, i noticed if i move self.MenuBar = None into function
> initProperties, it
> doesn't work. is it the original intention? i tried put in there
> first because
> Paul showed me
> something like this in his earlier reply:
>
> def initProperties(self):
> self.MenuBar = MyMenuBar()
>
> thank you.
This is incorrect. What you want to do is set the MenuBarClass in
initProperties(). This way, when it is time to create the menu bar,
it will use your custom class instead of the default. Alternatively,
if you set the MenuBarClass to None in initProperties(), no menu bar
is created.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
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")
lbl = dabo.ui.dLabel(self.pnl, Alignment="Left", Caption="This
is a
test.")
btn = dabo.ui.dButton(self.pnl, Caption = "OK", RegID="btnOk",
OnHit=self.onOkButton)
mainSz.append(lbl, halign="center", border=20,
borderSides=("left",
"right"))
mainSz.append(btn, halign="right", border=10)
def initProperties(self):
self.Caption = "TestForm"
self.Size = (200, 400)
self.Position = (300, 200)
def onOkButton(self, evt):
dabo.ui.info("Cool, it worked!")
if __name__ == "__main__":
app = dabo.dApp()
app.MainFormClass = TestForm
app.start()
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users