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