Hello,
I am trying to create some composit controls, a Float Spin Button with a climb rate, and a Logarthmic Spin Button. However, I am a little bit lost and I am looking for documentation on how to do that.
In a first attempt I have put a SpinButton and a TextCtrl together in a BoxSizer, which the class inherits from. Unfortunately, the spinbutton event is not cought by anything and the SetValue callback not executed. But what should be the parent class(es) ? Can I handle internal events within the class ? Can the class emitt a signal once the value has been validated?
Thanks for any hints.
peter
class wxFloatSpin(wxBoxSizer):
def __init__(self,parent,ID=-1,
minval=0.0,maxval=1.0,initial=0.0,rate=1.0):
wxBoxSizer.__init__(self,wxHORIZONTAL)
if ID == -1: ID = wxNewId()
self.maxval = maxval
self.minval = minval
self.value = initial
self.rate = rate
self.text = wxTextCtrl(parent,ID,value=str(initial))
self.SBID = wxNewId()
self.SB = wxSpinButton(parent, self.SBID)
self.SB.SetRange(-100,100)
self.SB.SetValue(0)
EVT_SPINCTRL(parent, self.SBID, self.SetValue)
self.Add(self.text, 1, wxALIGN_RIGHT, 0)
self.Add(self.SB, 1, wxALIGN_RIGHT, 0)
def SetValue(self,event):
value = self.text.GetValue()
print value
if __name__ == '__main__':
class TestFrame(wxFrame):
def __init__(self):
wxFrame.__init__ (self, None, -1, "Float Spinner")
text = wxStaticText(self, -1, "Float Spinner",(200, 30))
spin = wxFloatSpin(self, -1, 1, 1000000, 2, [1.0,2.0,5.0])
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(text, 0, wxALIGN_LEFT, 0)
sizer.Add(spin, 0, wxALIGN_LEFT, 0)
self.SetSizer(sizer)
app = wxPySimpleApp()
frame = TestFrame()
frame.Show(true)
app.MainLoop()