SpinCtrl events problem

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,301
Messages
2,571,549
Members
48,295
Latest member
JayKillian
Top