[wxPython-users] float / log - slider, deriving from wx.Slider ?

Stef Mientki s.mientki at ru.nl
Sat Mar 1 17:39:49 PST 2008



Stef Mientki wrote:
>
>
> Robin Dunn wrote:
>> Stef Mientki wrote:
>>> hello,
>>>
>>> I'm trying to create a float / log slider,
>>> by deriving from wx.Slider.
>>>
>>
>>
>> You'll probably have better luck if you use a composite control.  
>> Simply derive a class from wx.Panel and put your slider and static 
>> texts on that panel in a sizer.  You can then add methods that 
>> forward calls to the slider's methods if needed, or add others that 
>> are specific to the functionality of the composite.  Then when you 
>> want to use one of these you just create an instance of the composite 
>> class and use it as if it was a single control.
>>
> thanks Robin,
>
> that works like a charm ;-)
except for one problem, for which I can't find a solution:
I created a "new widget", derived from a panel (not a combination of 
panel and slider),
and simply create a slider in the __init__ of the panel,
this works perfect, even in AUI parent panels.

Now when the slider is moved by the user,
I need to perform actions both in the panel that contains the slider (to 
update the value label),
and in the parent of that panel, or even higher  (to perform my 
functional actions).

Now both event handlers are triggered,
but in the top panel I don't get the ID of the slider but of the ID of 
the first panel containing the slider,
in fact the ID of my "new widget" (sounds logical ;-)

Now the first handler that is triggered is the event handler of the 
slider itself,
so in that handler I tried to change the eventID in the event handler, by:
   event.SetId ( self.Slider.GetId )
but that doesn't work.

As everything is dynamically, I don't know that my "new widget" contains 
subcontrols.
My highest event handler, should handle all user events,
so it tries to find out which control fired the event, by comparing the 
ID's of the event.

Any hints ?

thanks,
Stef Mientki





More information about the wxpython-users mailing list