Search code examples
python-3.xsubclassingpyqtgraph

Subclassing pyqtgraph.ParameterTree issue


I've been using the ParameterTree class very effectively, I like it a lot! I have a lot of parameters so I thought of subclassing ParameterTree in order to clear up some code. Unfortunately when I do this I get a weird-looking non-functional ParameterTree:

enter image description here

All the edit fields and comboboxes are gone

This is how I'm subclassing it

class CamParamTree(ParameterTree):

    def __init__(self, *args, **kwargs):
        super(ParameterTree, self).__init__(*args, **kwargs)
        params = [.......]
        self.p = Parameter.create(name='params', type='group', children=params)
        self.setParameters(self.p, showTop=False)

and then in the main GUI I instanciate it like this:

class GUI(QtGui.QMainWindow):

    def __init__(self, *args, **kwargs):
       self.tree = CamParamTree()

What am I doing wrong?

Cheers


Solution

  • Just a simple error: you need

    super(CamParamTree, self).__init__(*args, **kwargs)
    

    instead of

    super(ParameterTree, self).__init__(*args, **kwargs)