M
mardif
Hi,
I've a problem with wx.SpinCtrl
Here we go with my source code:
import wx
import traceback
class TextPage(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "")
box = wx.BoxSizer(wx.VERTICAL)
self.spin = wx.SpinCtrl(self, -1)
box.Add(self.spin)
self.SetSizer(box)
wx.EVT_SPINCTRL(self, self.spin.GetId(), self.spinCtrlEvent )
self.CenterOnScreen()
def spinCtrlEvent(self, evt):
pass
print "ALL RIGHT"
if __name__ == "__main__":
app = wx.PySimpleApp(0)
p = TextPage()
p.Show()
app.MainLoop()
Now, my problem is the increment/decrement of self.spin value.
The SpinCtrl object increment/decrement 1 unit at time.
I must increment/decrement "n" unit at time, ex: 5,10,15,20....
I've tried:
def __init__(self):
........
........
self.old_quantity = 0
def spinCtrlEvent(self, evt):
if ( evt.GetInt() > self.old_quantity ):
qta = self.old_quantity + 5
else:
qta = self.old_quantity - 5
self.old_quantity = qta
self.spin.SetValue( qta )
But here the process it goes in loop, because the SetValue SpinCtrl
method regenerates the EVT_SPINCTRL event
Any idea?
Thanks very much
I've a problem with wx.SpinCtrl
Here we go with my source code:
import wx
import traceback
class TextPage(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "")
box = wx.BoxSizer(wx.VERTICAL)
self.spin = wx.SpinCtrl(self, -1)
box.Add(self.spin)
self.SetSizer(box)
wx.EVT_SPINCTRL(self, self.spin.GetId(), self.spinCtrlEvent )
self.CenterOnScreen()
def spinCtrlEvent(self, evt):
pass
print "ALL RIGHT"
if __name__ == "__main__":
app = wx.PySimpleApp(0)
p = TextPage()
p.Show()
app.MainLoop()
Now, my problem is the increment/decrement of self.spin value.
The SpinCtrl object increment/decrement 1 unit at time.
I must increment/decrement "n" unit at time, ex: 5,10,15,20....
I've tried:
def __init__(self):
........
........
self.old_quantity = 0
def spinCtrlEvent(self, evt):
if ( evt.GetInt() > self.old_quantity ):
qta = self.old_quantity + 5
else:
qta = self.old_quantity - 5
self.old_quantity = qta
self.spin.SetValue( qta )
But here the process it goes in loop, because the SetValue SpinCtrl
method regenerates the EVT_SPINCTRL event
Any idea?
Thanks very much