From 9a2d127e306e15a2589583f40e3ac7574424ee17 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Wed, 19 Mar 2014 12:14:54 +0100 Subject: [PATCH] added class MPLWidget in order to create updatable Matplotlib Figures within a Qt GUI --- pylot/core/util/widgets.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pylot/core/util/widgets.py diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py new file mode 100644 index 00000000..d99fe947 --- /dev/null +++ b/pylot/core/util/widgets.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Mar 19 11:27:35 2014 + +@author: sebastianw +""" + +import matplotlib + +matplotlib.use('Qt4Agg') +matplotlib.rcParams['backend.qt4'] = 'PySide' + +from matplotlib.figure import Figure +from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg + + +class MPLWidget(FigureCanvasQTAgg): + + def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'): + super(MPLWidget, self).__init__(Figure()) + + self.setParent(parent) + self.figure = Figure() + self.canvas = FigureCanvasQTAgg(self.figure) + self.axes = self.figure.add_subplot(111) + + self.axes.set_xlabel(xlabel) + self.axes.set_ylabel(ylabel) + self.axes.set_title(title)