]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/SpinButton.py
wxUSE_*BOOK checks.
[wxWidgets.git] / wxPython / demo / SpinButton.py
CommitLineData
8fa876ca
RD
1# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o EVT_SPIN events (or something about them) freezes up the app.
4#
cf694132 5
8fa876ca 6import wx
cf694132 7
cf694132
RD
8#----------------------------------------------------------------------
9
8fa876ca 10class TestPanel(wx.Panel):
cf694132 11 def __init__(self, parent, log):
8fa876ca 12 wx.Panel.__init__(self, parent, -1)
cf694132
RD
13 self.log = log
14 self.count = 0
15
95bfd958 16 wx.StaticText(self, -1, "This example uses the wx.SpinButton control.", (45, 15))
cf694132 17
8fa876ca 18 self.text = wx.TextCtrl(self, -1, "1", (30, 50), (60, -1))
cf694132 19 h = self.text.GetSize().height
6ab5d488 20 w = self.text.GetSize().width + self.text.GetPosition().x
8fa876ca 21
6ab5d488 22 self.spin = wx.SpinButton(self, -1, (w + 6, 50), (h/2, h), wx.SP_VERTICAL)
cf694132
RD
23 self.spin.SetRange(1, 100)
24 self.spin.SetValue(1)
25
8fa876ca 26 self.Bind(wx.EVT_SPIN, self.OnSpin, self.spin)
cf694132
RD
27
28
29 def OnSpin(self, event):
30 self.text.SetValue(str(event.GetPosition()))
31
32
33#----------------------------------------------------------------------
34
35def runTest(frame, nb, log):
36 win = TestPanel(nb, log)
37 return win
38
39#----------------------------------------------------------------------
40
41
cf694132 42overview = """\
95bfd958 43A wx.SpinButton has two small up and down (or left and right) arrow buttons.
8fa876ca 44It is often used next to a text control for increment and decrementing a value.
95bfd958 45Portable programs should try to use wx.SpinCtrl instead as wx.SpinButton is not
8fa876ca 46implemented for all platforms (Win32 and GTK only currently).
1fded56b 47
95bfd958 48NB: the range supported by this control (and wx.SpinCtrl) depends on the platform
8fa876ca
RD
49but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version
50of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit
51range is supported.
1fded56b 52
8fa876ca 53"""
1fded56b
RD
54
55if __name__ == '__main__':
56 import sys,os
57 import run
8eca4fef 58 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])