Skip to content

Backend plt/gcf refactor #2624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5501f4e
first steps to extract FigureManager* and friends from pyplot
tacaswell Nov 29, 2013
373909d
split backend_qt4 into two parts, with and without Gcf
tacaswell Nov 29, 2013
3014931
split backend_qt4agg into two parts.
tacaswell Nov 29, 2013
37e600e
Added a demo-file to show how to use the FigureManager classes to
tacaswell Nov 29, 2013
82f3dea
removed un-needed import of Gcf
tacaswell Nov 29, 2013
1ad0ebf
pep8 on backend_gtk.py
tacaswell Dec 3, 2013
58ea364
pep8 clean up in backend_gdk
tacaswell Dec 3, 2013
f355c0c
removed un-needed Gcf import
tacaswell Dec 3, 2013
d5e47fb
split backend_gcf into two parts,
tacaswell Dec 3, 2013
87781c5
pep8 on backend_gtkagg.py
tacaswell Dec 3, 2013
ce7c2ac
split backend_gktagg.py in to two parts
tacaswell Dec 3, 2013
ec24d0c
updated exclude list
tacaswell Dec 3, 2013
d3ecb67
pep8 clean up on backend_gtk3.py
tacaswell Dec 3, 2013
26fc122
split backend_gtk3 into two parts
tacaswell Dec 3, 2013
fe7cdc0
updated coding standards
tacaswell Dec 3, 2013
b099ddd
pep8 on backend_gtkcairo.py
tacaswell Dec 4, 2013
70939fe
split backend_gtkcairo.py into Gcf dependent and independent
tacaswell Dec 4, 2013
4ec7908
import from _backend_bases in backend_agg to avoid implicit Gcf import
tacaswell Dec 4, 2013
4f9f5b5
pep8 on backend_agg.py
tacaswell Dec 4, 2013
03e86ee
split backend_gtk3agg.py into two parts, the gcf dependent and
tacaswell Dec 4, 2013
d97d98f
updated coding standards exclude list
tacaswell Dec 4, 2013
83caa44
pep8 on backend_gtk3cairo.py
tacaswell Dec 4, 2013
9e74042
pep8 on backend_cairo.py
tacaswell Dec 4, 2013
51ccd5e
changed backend_cairo.py to import from _backend_bases to avoid
tacaswell Dec 4, 2013
efb1881
updated coding standards
tacaswell Dec 4, 2013
f4bdd22
Split backend_gtk3cairo.py into two parts, one dependent on Gcf
tacaswell Dec 4, 2013
a4bda49
Updated embedding_with_qt4_manager.py
tacaswell Dec 5, 2013
407b1ee
Improved class-aliases in _backend_qt*.py
tacaswell Dec 5, 2013
03c43aa
adjusting imports
fariza Dec 18, 2013
35afa92
renamed _backend_bases.py -> base_backend_bases.py
tacaswell Jan 30, 2014
2b213c0
massive rename operation
tacaswell Jan 30, 2014
93fc457
removed rouge merge notation
tacaswell Jan 30, 2014
6401be2
fixed broken import
tacaswell Jan 30, 2014
3ea9f08
pep8 on backend_tkagg.py
tacaswell Jan 30, 2014
b528125
pep8 conformance
tacaswell Jan 31, 2014
1dde78d
removed files that no longer exist
tacaswell Jan 31, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions examples/user_interfaces/embedding_with_qt4_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env python

# embedding_in_qt4.py --- Simple Qt4 application embedding matplotlib canvases
#
# Copyright (C) 2005 Florent Rougon
# 2006 Darren Dale
#
# This file is an example program for matplotlib. It may be used and
# modified with no restriction; raw copies as well as modified versions
# may be distributed without limitation.

from __future__ import unicode_literals, division
import sys
import os

from matplotlib.backends.qt4_compat import QtCore, QtGui
import numpy as np
from matplotlib.backends._backend_qt4agg import (FigureCanvas,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the import should be base_backend_qt4agg?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, also missed that when I did the re-naming.

FigureManager,
new_figure_manager)

from matplotlib.figure import Figure

progname = os.path.basename(sys.argv[0])
progversion = "0.1"


def demo_plot(ax):
"""
Plots sin waves with random period
"""
k = np.random.random_integers(1, 10)
th = np.linspace(0, 2*np.pi, 1024)
ax.plot(th, np.sin(th * k))


class ApplicationWindow(QtGui.QMainWindow):
def __init__(self):
# QT boiler plate to set up main window
QtGui.QMainWindow.__init__(self)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setWindowTitle("application main window")

self.file_menu = QtGui.QMenu('&File', self)
self.file_menu.addAction('&Quit', self.fileQuit,
QtCore.Qt.CTRL + QtCore.Qt.Key_Q)
self.menuBar().addMenu(self.file_menu)

self.help_menu = QtGui.QMenu('&Help', self)
self.menuBar().addSeparator()
self.menuBar().addMenu(self.help_menu)

self.help_menu.addAction('&About', self.about)

self.main_widget = QtGui.QWidget(self)

l = QtGui.QVBoxLayout(self.main_widget)
button = QtGui.QPushButton("make window A")
button.clicked.connect(self.new_window_hard_way)
l.addWidget(button)

buttonB = QtGui.QPushButton("make window B")
buttonB.clicked.connect(self.new_window_easy_way)
l.addWidget(buttonB)
self.main_widget.setFocus()
self.setCentralWidget(self.main_widget)
self._figs = []
self.statusBar().showMessage("All hail matplotlib!", 2000)

def new_window_hard_way(self):
# make a figure
fig = Figure()
# make a canvas
canvas = FigureCanvas(fig)
# make a manager from the canvas
manager = FigureManager(canvas, 1)
# grab an axes in the figure
ax = fig.gca()
# plot some demo code
demo_plot(ax)
# show the window
manager.show()

def new_window_easy_way(self):
# make a new manager
manager = new_figure_manager(2)
# grab a reference to the figure
fig = manager.canvas.figure
# get an axes object in the figure
ax = fig.gca()
# plot some demo-data
demo_plot(ax)
# show the window
manager.show()

def fileQuit(self):
self.close()

def closeEvent(self, ce):
self.fileQuit()

def about(self):
QtGui.QMessageBox.about(self, "About",
"""embedding_in_qt4.py example
Copyright 2005 Florent Rougon, 2006 Darren Dale, 2013 Thomas Caswell

This program is a simple example of a Qt4 application making use of
the FigureManager class.

It may be used and modified with no restriction; raw copies as well as
modified versions may be distributed without limitation."""
)


qApp = QtGui.QApplication(sys.argv)

aw = ApplicationWindow()
aw.setWindowTitle("%s" % progname)
aw.show()
sys.exit(qApp.exec_())
#qApp.exec_()
Loading