mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Added support for callback function
This commit is contained in:
parent
4f2d4d337e
commit
8cfef6c08d
@ -19,6 +19,7 @@ class WxSlider(wx.Slider):
|
||||
intMin = 0
|
||||
intMax = 100
|
||||
self.textValue = None
|
||||
self.updateCB = None
|
||||
|
||||
if style & wx.SL_HORIZONTAL:
|
||||
newStyle = wx.SL_HORIZONTAL
|
||||
@ -57,6 +58,8 @@ class WxSlider(wx.Slider):
|
||||
# update textValue from slider
|
||||
self.textValue.Clear()
|
||||
self.textValue.WriteText("%.2f"%self.GetValue())
|
||||
if self.updateCB: # callback function sould receive event as the argument
|
||||
self.updateCB(event)
|
||||
event.Skip()
|
||||
|
||||
def onEnter(self, event):
|
||||
@ -65,8 +68,13 @@ class WxSlider(wx.Slider):
|
||||
return
|
||||
intVal = 100.0 / (self.maxValue - self.minValue) * (float(self.textValue.GetValue()) - self.minValue)
|
||||
wx.Slider.SetValue(self, intVal)
|
||||
if self.updateCB: # callback function should receive event as the argument
|
||||
self.updateCB(event)
|
||||
event.Skip()
|
||||
|
||||
def bindFunc(self, updateCB):
|
||||
self.updateCB = updateCB
|
||||
|
||||
def Disable(self):
|
||||
# overriding wx.Slider.Disable()
|
||||
wx.Slider.Disable(self)
|
||||
|
Loading…
x
Reference in New Issue
Block a user