PlotPyStack / PythonQwt

Qt plotting widgets for Python (pure Python reimplementation of Qwt C++ library)
https://pypi.org/project/PythonQwt/
Other
87 stars 25 forks source link

allow spurius parameters in QwtPlotDict __init__ #75

Closed ZeeD closed 1 year ago

ZeeD commented 1 year ago

QwtPlot extends QFrame and QwtPlotDict. QFrame's __init__ expect up to 2 parameters, and - at least with current pyside - supports cooperative multiple inheritance. this means that internally QFrame.__init__ will call QwtPlotDict.__init__, forwarding all the parameters.

fixes: #74

a (simplified) simulation of the problem:

current:

class QwtPlotDict:
    def __init__(self):
        print(f'QwtPlotDict.__init__()')

class QFrame:
    def __init__(self, *args):
        print(f'QFrame.__init__({args})')
        super().__init__(*args)

class QwtPlot(QFrame, QwtPlotDict):
    def __init__(self, parent = None):
        print(f'QwtPlot.__init__({parent})')
        QwtPlotDict.__init__(self)
        QFrame.__init__(self, parent)

plot = QwtPlot()

with fix:

class QwtPlotDict:
    def __init__(self, *_):
        print(f'QwtPlotDict.__init__()')

class QFrame:
    def __init__(self, *args):
        print(f'QFrame.__init__({args})')
        super().__init__(*args)

class QwtPlot(QFrame, QwtPlotDict):
    def __init__(self, parent = None):
        print(f'QwtPlot.__init__({parent})')
        super().__init__(parent)

plot = QwtPlot()
PierreRaybaut commented 1 year ago

I've used a slightly different approach, see #74