[wxPython-users] Re: slider.SetValue(x) doesnt send a slider
event
Robin Dunn
robin at alldunn.com
Fri Sep 29 12:28:01 PDT 2006
Jim Carroll wrote:
>>> How can I have my slider generate an EVT_SLIDER when I set its value?
>> The general rule in wxWidgets is that events are not sent when values
>> are changed programatically. (There are exceptions to this, mainly
>> those that were already sending an event before the rule was made.) So
>> your options are to either send the event yourself, or refactor your
>> event handler so it calls another method to do its work that you can
>> also call yourself after doing the SetValue.
>>
>
> Ok, I'll send the event myself...
>
> Here's my first guess... it's not quite working:
>
> # have the slider emit an event
> evt = wx.CommandEvent(100, self.minSlider.GetId())
Instead of the 100 use wx.wxEVT_COMMAND_SLIDER_UPDATED. Otherwise it
won't match bindings made with EVT_SLIDER.
> evt.SetEventObject(self.minSlider)
> evt.SetInt(lum)
> self.minSlider.ProcessEvent(evt)
> #wx.PostEvent(self.minSlider, evt)
>
> I've tried the post, and the process...
Either will send the event. The former will send it during the
ProcessEvent call, the latter will send it before the next idle event.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list