2003-12-08 20:23:28 -05:00
|
|
|
# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o EVT_SPIN events (or something about them) freezes up the app.
|
|
|
|
#
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestPanel(wx.Panel):
|
1999-04-29 23:29:54 -04:00
|
|
|
def __init__(self, parent, log):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
1999-04-29 23:29:54 -04:00
|
|
|
self.log = log
|
|
|
|
self.count = 0
|
|
|
|
|
2004-01-12 22:17:17 -05:00
|
|
|
wx.StaticText(self, -1, "This example uses the wx.SpinButton control.", (45, 15))
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.text = wx.TextCtrl(self, -1, "1", (30, 50), (60, -1))
|
1999-04-29 23:29:54 -04:00
|
|
|
h = self.text.GetSize().height
|
2004-06-14 15:10:20 -04:00
|
|
|
w = self.text.GetSize().width + self.text.GetPosition().x
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2004-06-14 15:10:20 -04:00
|
|
|
self.spin = wx.SpinButton(self, -1, (w + 6, 50), (h/2, h), wx.SP_VERTICAL)
|
1999-04-29 23:29:54 -04:00
|
|
|
self.spin.SetRange(1, 100)
|
|
|
|
self.spin.SetValue(1)
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.Bind(wx.EVT_SPIN, self.OnSpin, self.spin)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
def OnSpin(self, event):
|
|
|
|
self.text.SetValue(str(event.GetPosition()))
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
2004-01-12 22:17:17 -05:00
|
|
|
A wx.SpinButton has two small up and down (or left and right) arrow buttons.
|
2003-12-08 20:23:28 -05:00
|
|
|
It is often used next to a text control for increment and decrementing a value.
|
2004-01-12 22:17:17 -05:00
|
|
|
Portable programs should try to use wx.SpinCtrl instead as wx.SpinButton is not
|
2003-12-08 20:23:28 -05:00
|
|
|
implemented for all platforms (Win32 and GTK only currently).
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2004-01-12 22:17:17 -05:00
|
|
|
NB: the range supported by this control (and wx.SpinCtrl) depends on the platform
|
2003-12-08 20:23:28 -05:00
|
|
|
but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version
|
|
|
|
of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit
|
|
|
|
range is supported.
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
"""
|
2003-07-02 19:13:10 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|