diff options
author | erg_samowzbudnik <uinarf@autistici.org> | 2021-06-01 15:11:52 +0200 |
---|---|---|
committer | erg_samowzbudnik <uinarf@autistici.org> | 2021-06-01 15:11:52 +0200 |
commit | a2a05d9e9d9245be4c6e4e9c70334b8ac5fc299b (patch) | |
tree | b44a805bfcff41d82c8cfc19cb2e92cc4af1b56d /mplwidget.py | |
download | RPGH-a2a05d9e9d9245be4c6e4e9c70334b8ac5fc299b.tar.gz RPGH-a2a05d9e9d9245be4c6e4e9c70334b8ac5fc299b.tar.bz2 RPGH-a2a05d9e9d9245be4c6e4e9c70334b8ac5fc299b.zip |
Initial commit of a beta version.
Diffstat (limited to 'mplwidget.py')
-rw-r--r-- | mplwidget.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/mplwidget.py b/mplwidget.py new file mode 100644 index 0000000..df3a054 --- /dev/null +++ b/mplwidget.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +__author__ = "Franek Łazarewicz-Muradyan" +__copyright__ = "Copyright 2021, Franek Łazarewicz-Muradyan" +__version__ = "0.1" +__status__ = "Beta" +__email__ = "uinarf@autistici.org" + +from PyQt5 import QtWidgets +from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas +from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as \ +NavigationToolbar +from matplotlib.figure import Figure +from matplotlib import gridspec + +#matplotlib.use('QT5Agg') + +class MplCanvas(FigureCanvas): + def __init__(self): + self.fig = Figure(tight_layout=True) + grid = gridspec.GridSpec(ncols=32, nrows=3) + self.ax = self.fig.add_subplot(grid[0, 0:32]) + self.ax_1 = self.fig.add_subplot(grid[1, 0:32]) + self.ax_2 = self.fig.add_subplot(grid[2, 0:32]) + self.fig.align_labels() + FigureCanvas.__init__(self, self.fig) + FigureCanvas.setSizePolicy(self, + QtWidgets.QSizePolicy.Expanding, + QtWidgets.QSizePolicy.Expanding) + FigureCanvas.updateGeometry(self) + +class MplWidget(QtWidgets.QWidget): + def __init__(self, parent = None): + QtWidgets.QWidget.__init__(self, parent) + self.canvas = MplCanvas() + self.toolbar = NavigationToolbar(self.canvas, self) + self.vbl = QtWidgets.QVBoxLayout() + self.vbl.addWidget(self.toolbar) + self.vbl.addWidget(self.canvas) + self.setLayout(self.vbl) |