Problems with current value of wx.SpinCtrl and EVT_SPIN
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/ChallengeDemos#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_CHANGED 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.Frame): def OnSpinGeneral(self, 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.GetValue() self.slider.SetValue(self.spin.GetValue()) def OnScrollChanged(self, event): self.spin.SetValue(self.slider.GetValue()) def __init__(self): wx.Frame.__init__( self, None, -1, "", #size=FRAME_SIZE, style=wx.DEFAULT_FRAME_STYLE ) self.sizer = wx.BoxSizer( wx.VERTICAL ) self.spin = wx.SpinCtrl(self, 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.EVT_SCROLL_CHANGED, self.OnScrollChanged, self.slider) self.Bind(wx.EVT_SPIN_UP, self.OnSpin, self.spin) self.Bind(wx.EVT_SPIN_DOWN, self.OnSpin, self.spin) self.Bind(wx.EVT_SPIN, self.OnSpinGeneral, self.spin) self.SetSizer(self.sizer) self.SetAutoLayout(1) self.Show(1) app = wx.PySimpleApp() frame = AppFrame() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
Re: wxStyledTextCtrl - Dead?
The wxPython Demo (http://prdownloads.sourceforge.net/wxpython/wxPython-demo-2.6.3.2.tar.gz) still contains the wxStyledTextCtrl: wx.stc.StyledTextCtrl The demo is probably also a good example of how to use wxStyledTextCtrl. Basic information can be found on http://www.yellowbrain.com/stc/init_repr.html Regards. David Rasmussen schrieb: > I have several questions about wxStyledTextCtrl: > > 1) Is it still being maintained? > > 2) Where are the docs and tutorials? > > 3) Is it wxStyledTextCtrl, wx.StyledTextCtrl, StyledTextCtrl, or... ? > > 4) Is there an alternative? > > /David -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with current value of wx.SpinCtrl and EVT_SPIN
Yes, it "works". However buggy. When the slider is set to 0 and the up button is pressed in the SpinCtrl, the value in the SpinCtrl will be 1, but the slider will not move. There's also a discrepancy between the value displayed in the SpinCtrl and the value output by print self.spin.GetValue(). When playing with this code I also noticed that I was not able change the behaviour of the up and down buttons. I expected that if I modify OnSpin in the following way: def OnSpin(self, event): pass That pressing the spin buttons would have no effect. However, the value is still increased or decreased -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with current value of wx.SpinCtrl and EVT_SPIN
Just found a solution to the problem: when using wx.EVT_SPINCTRL instead of wx.EVT_SPIN_UP, wx.EVT_SPIN_DOWN or wx.EVT_SPIN the program behaves correctly. wxWidget documentation for wxSpinCtrl states that "You may also use the wxSpinButton event macros, however the corresponding events will not be generated under all platforms"; I ran the program on WinXP SP2. However, the events seem to be handled (at least EVT_SPIN_UP, wx.EVT_SPIN_DOWN). So I do not understand why handling these events leads to a buggy behaviour. -- http://mail.python.org/mailman/listinfo/python-list