Hello,
I am new to Python/wxPython and am experiencing first problems. I have
a dialog which includes a SpinCtrl and a Slider. I want the Slider to
affect the SpinCtrl and vice versa
(http://wiki.wxpython.org/index.cgi/C...geDemos#Part1).
The code I wrote does, however, not work correctly. The event EVT_SPIN
is never handled (even though I wrote a handler), and in the handler of
EVT_SCROLL_CHAN GED I do not obtain the modified value, but the value
before the control has changed.
Any feedback would be greatly appreciated.
To clarify my problem, here's the code (Python2.4, wxPython 2.6) :
import wx
class AppFrame(wx.Fra me):
def OnSpinGeneral(s elf, event):
b = wx.MessageBox(" never reached")
def OnSpin(self, event):
# I tried to use Skip so that the changing of the value would
take place before
# I invoke GetValue(), however this has no effect
event.Skip()
print self.spin.GetVa lue()
self.slider.Set Value(self.spin .GetValue())
def OnScrollChanged (self, event):
self.spin.SetVa lue(self.slider .GetValue())
def __init__(self):
wx.Frame.__init __( self,
None, -1, "",
#size=FRAME_SIZ E,
style=wx.DEFAUL T_FRAME_STYLE )
self.sizer = wx.BoxSizer( wx.VERTICAL )
self.spin = wx.SpinCtrl(sel f, min = 0, max = 50)
self.slider = wx.Slider(self, 1, 6, 0, 50)
self.sizer.Add( self.spin)
self.sizer.Add( self.slider)
self.Bind(wx.EV T_SCROLL_CHANGE D, self.OnScrollCh anged,
self.slider)
self.Bind(wx.EV T_SPIN_UP, self.OnSpin, self.spin)
self.Bind(wx.EV T_SPIN_DOWN, self.OnSpin, self.spin)
self.Bind(wx.EV T_SPIN, self.OnSpinGene ral, self.spin)
self.SetSizer(s elf.sizer)
self.SetAutoLay out(1)
self.Show(1)
app = wx.PySimpleApp( )
frame = AppFrame()
app.MainLoop()