Extending DirectSlider (Inheritance)

Hi,

I’m trying to create my own DirectSlider that have multiple thumbs. I’m having problems with defining my constructor:

class MultipleDirectSlider(DirectSlider):
    """
    """
    def __init__(self, parent = None, **kw):
        """
        """
        # Call the parent's constructor
        DirectSlider.__init__(self,parent,**kw)
        
        # For the other thumbs
        #self.thumbs = []
        
    def addThumb(self,**params):
        """
        Add a new thumb to the Sliderbar
        """
        # Get the required params
        thumb = self.createcomponent("thumb", (), None,
                                      DirectButton, (self,),
                                      borderWidth = self['borderWidth'])
                                      
        self.thumbs.append(thumb) 
        
        # Return the position of the Event    
        return len(self.thumbs) -1'''

What I get from running this code is the Sliderbar, sans bar. I don’t understand what I’m doing wrong.

Thanks.

The DirectSlider is a thin wrapper around the C++ class PGSliderBar, which is hardcoded with support for only one thumb. You won’t be able to add multiple thumbs without rewriting the underlying C++ class.

Your best bet to implement a slider with multiple thumbs is to write the whole thing in Python, without relying on DirectSlider or PGSliderBar.

David