dabo Commit
Revision 4635
Date: 2008-11-02 12:27:05 -0800 (Sun, 02 Nov 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4635
Changed:
U trunk/demo/samples/dSpinner.py
Log:
Moved the current self-test code into the Demo sample code.
Diff:
Modified: trunk/demo/samples/dSpinner.py
===================================================================
--- trunk/demo/samples/dSpinner.py 2008-11-02 20:15:04 UTC (rev 4634)
+++ trunk/demo/samples/dSpinner.py 2008-11-02 20:27:05 UTC (rev 4635)
@@ -8,41 +8,99 @@
class TestPanel(dabo.ui.dPanel):
def afterInit(self):
sz = self.Sizer = dabo.ui.dSizer("v")
-
- lbl = dabo.ui.dLabel(self, Alignment="Center", WordWrap=True,
Width=400,
- Caption=_("Both of these spinners have a range
from 0 to 10. The only "
- "difference is that the top
spinner has its SpinnerWrap property set to "
- "True, which cycles it around
when it reaches one of its limits."))
-
- lbl.FontSize += 3
- lbl.ForeColor = "darkBlue"
- sz.appendSpacer(25)
- sz.append(lbl, halign="center")
- sz.appendSpacer(10)
-
- lbl = dabo.ui.dLabel(self, Caption=_("Spinner with wrapping"))
- spn = dabo.ui.dSpinner(self, Value=5, Max=10,
- Min=0, SpinnerWrap=True, Name="wrapSpinner")
+ sz.appendSpacer(50)
+ spn = self.spinner = dabo.ui.dSpinner(self, Max=25, Min=0,
Value=4.75,
+ Increment=1.25, SpinnerWrap=False, FontSize=12,
Width=100)
spn.bindEvent(dEvents.Hit, self.onSpinnerHit)
- sz.append(lbl, halign="center")
+ spn.bindEvent(dEvents.SpinUp, self.onSpinUp)
+ spn.bindEvent(dEvents.SpinDown, self.onSpinDown)
+ spn.bindEvent(dEvents.Spinner, self.onSpinner)
sz.append(spn, halign="center")
- sz.appendSpacer(20)
- lbl = dabo.ui.dLabel(self, Caption=_("Spinner without
wrapping"))
- spn = dabo.ui.dSpinner(self, Value=5, Max=10,
- Min=0, SpinnerWrap=False, Name="nowrapSpinner")
- spn.bindEvent(dEvents.Hit, self.onSpinnerHit)
+ lbl = dabo.ui.dLabel(self, Caption=_("Spinner Properties"),
FontSize=18,
+ FontBold=True)
+ sz.appendSpacer(10)
sz.append(lbl, halign="center")
- sz.append(spn, halign="center")
+ sz.appendSpacer(4)
+ gsz = dabo.ui.dGridSizer(MaxCols=2, HGap=4, VGap=6)
+ lbl = dabo.ui.dLabel(self, Caption="Min")
+ txt = dabo.ui.dTextBox(self, DataSource=spn, DataField="Min",
StrictNumericEntry=False)
+ gsz.append(lbl, halign="right")
+ gsz.append(txt)
+ lbl = dabo.ui.dLabel(self, Caption="Max")
+ txt = dabo.ui.dTextBox(self, DataSource=spn, DataField="Max",
StrictNumericEntry=False)
+ gsz.append(lbl, halign="right")
+ gsz.append(txt)
+ lbl = dabo.ui.dLabel(self, Caption="Increment")
+ txt = dabo.ui.dTextBox(self, DataSource=spn,
DataField="Increment", StrictNumericEntry=False)
+ gsz.append(lbl, halign="right")
+ gsz.append(txt)
+ lbl = dabo.ui.dLabel(self, Caption="SpinnerWrap")
+ chk = dabo.ui.dCheckBox(self, DataSource=spn,
DataField="SpinnerWrap")
+ gsz.append(lbl, halign="right")
+ gsz.append(chk)
+ lbl = dabo.ui.dLabel(self, Caption="FontSize")
+ txt = dabo.ui.dTextBox(self, DataSource=spn,
DataField="FontSize")
+ gsz.append(lbl, halign="right")
+ gsz.append(txt)
+ lbl = dabo.ui.dLabel(self, Caption="Height")
+ txt = dabo.ui.dTextBox(self, DataSource=spn, DataField="Height")
+ gsz.append(lbl, halign="right")
+ gsz.append(txt)
+ lbl = dabo.ui.dLabel(self, Caption="ForeColor")
+ txt = dabo.ui.dTextBox(self, ReadOnly=True, DataSource=spn,
DataField="ForeColor")
+ btn = dabo.ui.dButton(self, Caption="...",
OnHit=self.onForeColor, Width=36)
+ hsz = dabo.ui.dSizer("h")
+ hsz.append(txt, 1)
+ hsz.append(btn)
+ gsz.append(lbl, halign="right")
+ gsz.append(hsz)
+ lbl = dabo.ui.dLabel(self, Caption="BackColor")
+ txt = dabo.ui.dTextBox(self, ReadOnly=True, DataSource=spn,
DataField="BackColor")
+ btn = dabo.ui.dButton(self, Caption="...",
OnHit=self.onBackColor, Width=36)
+ hsz = dabo.ui.dSizer("h")
+ hsz.append(txt, 1)
+ hsz.append(btn)
+ gsz.append(lbl, halign="right")
+ gsz.append(hsz)
+ lbl = dabo.ui.dLabel(self, Caption="Enabled")
+ chk = dabo.ui.dCheckBox(self, DataSource=spn,
DataField="Enabled")
+ gsz.append(lbl, halign="right")
+ gsz.append(chk)
+ sz.append(gsz, halign="center")
+ self.update()
self.layout()
+
+
+ def onBackColor(self, evt):
+ color = dabo.ui.getColor(self.spinner.BackColor)
+ if color is not None:
+ self.spinner.BackColor = color
+ self.update()
+
+ def onForeColor(self, evt):
+ color = dabo.ui.getColor(self.spinner.ForeColor)
+ if color is not None:
+ self.spinner.ForeColor = color
+ self.update()
+ self.layout()
def onSpinnerHit(self, evt):
obj = evt.EventObject
- self.Form.logit("%s Hit; Value=%s" % (obj.Name, obj.Value))
+ self.Form.logit("Hit! (%s); Value=%s" % (evt.hitType,
obj.Value))
+ def onSpinUp(self, evt):
+ self.Form.logit("Spin up event.")
+
+ def onSpinDown(self, evt):
+ self.Form.logit("Spin down event.")
+
+ def onSpinner(self, evt):
+ self.Form.logit("Spinner event.")
+
category = "Controls.dSpinner"
overview = """
_______________________________________________
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]