]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/SpinButton.py
1 # 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
5 # 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
7 # o EVT_SPIN events (or something about them) freezes up the app.
12 #----------------------------------------------------------------------
14 class TestPanel(wx
.Panel
):
15 def __init__(self
, parent
, log
):
16 wx
.Panel
.__init
__(self
, parent
, -1)
20 wx
.StaticText(self
, -1, "This example uses the wxSpinButton control.", (45, 15))
22 self
.text
= wx
.TextCtrl(self
, -1, "1", (30, 50), (60, -1))
23 h
= self
.text
.GetSize().height
25 self
.spin
= wx
.SpinButton(self
, -1, (92, 50), (h
, h
), wx
.SP_VERTICAL
)
26 self
.spin
.SetRange(1, 100)
29 self
.Bind(wx
.EVT_SPIN
, self
.OnSpin
, self
.spin
)
32 def OnSpin(self
, event
):
33 self
.text
.SetValue(str(event
.GetPosition()))
36 #----------------------------------------------------------------------
38 def runTest(frame
, nb
, log
):
39 win
= TestPanel(nb
, log
)
42 #----------------------------------------------------------------------
46 A wxSpinButton has two small up and down (or left and right) arrow buttons.
47 It is often used next to a text control for increment and decrementing a value.
48 Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not
49 implemented for all platforms (Win32 and GTK only currently).
51 NB: the range supported by this control (and wxSpinCtrl) depends on the platform
52 but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version
53 of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit
58 if __name__
== '__main__':
61 run
.main(['', os
.path
.basename(sys
.argv
[0])])