mirror of
https://github.com/Athemis/PyDSF.git
synced 2025-04-05 14:46:03 +00:00
27 lines
No EOL
1 KiB
Python
27 lines
No EOL
1 KiB
Python
from PyQt5 import QtWidgets, QtGui, QtCore
|
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
|
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
|
|
from matplotlib.figure import Figure
|
|
|
|
class MplCanvas(FigureCanvas):
|
|
def __init__(self):
|
|
self.fig = Figure()
|
|
self.ax = self.fig.add_subplot(111)
|
|
FigureCanvas.__init__(self, self.fig)
|
|
FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
|
|
FigureCanvas.updateGeometry(self)
|
|
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
|
|
|
def clear(self):
|
|
self.ax.clear()
|
|
self.fig.clear()
|
|
|
|
class MplWidget(QtWidgets.QWidget):
|
|
def __init__(self, parent = None):
|
|
QtWidgets.QWidget.__init__(self, parent)
|
|
self.canvas = MplCanvas()
|
|
self.ntb = NavigationToolbar(self.canvas, self)
|
|
self.vbl = QtWidgets.QVBoxLayout()
|
|
self.vbl.addWidget(self.canvas)
|
|
self.vbl.addWidget(self.ntb)
|
|
self.setLayout(self.vbl) |