Tue, 15 May 2018 16:08:33 +0200
[qt5] fix QMplCanvas
pygpibtoolkit/qt5/mpl.py | file | annotate | diff | comparison | revisions |
--- a/pygpibtoolkit/qt5/mpl.py Fri May 04 01:00:59 2018 +0200 +++ b/pygpibtoolkit/qt5/mpl.py Tue May 15 16:08:33 2018 +0200 @@ -26,15 +26,13 @@ http://www.logilab.org/project/pygpibtoolkit -- mailto:david.douard@sdfa3.org """ +from PyQt5 import QtCore, QtWidgets -from PyQt5 import QtGui, QtCore, QtWidgets - -from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas +from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas from matplotlib.figure import Figure -class QMplCanvas(FigureCanvas): - """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).""" +class QMplCanvas(Canvas): def __init__(self, parent=None, width=5, height=4, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi) self.axes = self.fig.add_subplot(111) @@ -44,10 +42,9 @@ super().__init__(self.fig) self.setParent(parent) - FigureCanvas.setSizePolicy(self, - QtWidgets.QSizePolicy.Expanding, - QtWidgets.QSizePolicy.Expanding) - FigureCanvas.updateGeometry(self) + self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, + QtWidgets.QSizePolicy.Expanding) + self.updateGeometry() def sizeHint(self): w, h = self.get_width_height()