-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Short description
The MatplotlibWidget's signature is not compatiable with QWidget
Code to reproduce
I am not quite sure about this, but I think the MatplotlibWidget class is not compatiable with the QWidget class.
The MatplotlibWidget's init signature:
# MatplotlibWidget
def __init__(self, size=(5.0, 4.0), dpi=100):
...But the QWidget's init signature is like this:
# QWidget
def __init__(self, parent=None, flags=None):
...When I use pyuic5 to convert the .ui file to Python source that includes the custom MatplotlibWidget class, the generated code always assumes that the first argument is its parent, I have to modify the code every time I generate it, or I have to just use my own MatplotlibWidget class.
Expected behavior
Make the Matplotlibwidget compatiable with QWidget.
Real behavior
The Matplotlibwidget is not compatiable with QWidget.
The generated code by pyuic5 is usually like this:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
...
# Something like this
self.widget = MatplotlibWidget(self.centralwidget)
...
from pyqtgraph.widgets.MatplotlibWidget import MatplotlibWidgetPossible solutions
According to Qt conventions, we could define the following two overloaded methods:
from typing import overload
@overload
def __init__(self, size=(5.0, 4.0), dpi=100, parent=None):
...
@overload
def __init__(self, parent=None):
...Tested environment(s)
- PyQtGraph version: 0.12.4
- Qt Python binding: 5.15.2
- Python version: 3.9.12
- NumPy version: 1.22.4
- Operating system: Windows 10
- Installation method: pip