Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 46bebec

Browse filesBrowse files
committed
first commit
0 parents  commit 46bebec
Copy full SHA for 46bebec

File tree

Expand file treeCollapse file tree

8 files changed

+269
-0
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+269
-0
lines changed

‎.hgignore

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
\.pyc$
2+
\.pyo$
3+
\.settings$
4+
\.spyderproject$
5+
\.ropeproject$
6+
\.orig$
7+
\.DS_Store$
8+
^build/
9+
^dist/
10+
^bin/
11+
^pyqtdesignerplugins.egg-info/
12+
MANIFEST$
13+
\Thumbs.db

‎MANIFEST.in

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
recursive-include plugins *.*
2+
include MANIFEST.in

‎build_sdist.bat

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
del MANIFEST
2+
rmdir /S /Q build
3+
rmdir /S /Q dist
4+
python setup.py build sdist
5+
pause

‎matplotlibwidget.py

Copy file name to clipboard
+124Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright © 2009 Pierre Raybaut
4+
# Licensed under the terms of the MIT License
5+
6+
"""
7+
MatplotlibWidget
8+
================
9+
10+
Example of matplotlib widget for PyQt4
11+
12+
Copyright © 2009 Pierre Raybaut
13+
This software is licensed under the terms of the MIT License
14+
15+
Derived from 'embedding_in_pyqt4.py':
16+
Copyright © 2005 Florent Rougon, 2006 Darren Dale
17+
"""
18+
19+
__version__ = "1.0.0"
20+
21+
from PyQt4.QtGui import QSizePolicy
22+
from PyQt4.QtCore import QSize
23+
24+
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as Canvas
25+
from matplotlib.figure import Figure
26+
27+
from matplotlib import rcParams
28+
rcParams['font.size'] = 9
29+
30+
31+
class MatplotlibWidget(Canvas):
32+
"""
33+
MatplotlibWidget inherits PyQt4.QtGui.QWidget
34+
and matplotlib.backend_bases.FigureCanvasBase
35+
36+
Options: option_name (default_value)
37+
-------
38+
parent (None): parent widget
39+
title (''): figure title
40+
xlabel (''): X-axis label
41+
ylabel (''): Y-axis label
42+
xlim (None): X-axis limits ([min, max])
43+
ylim (None): Y-axis limits ([min, max])
44+
xscale ('linear'): X-axis scale
45+
yscale ('linear'): Y-axis scale
46+
width (4): width in inches
47+
height (3): height in inches
48+
dpi (100): resolution in dpi
49+
hold (False): if False, figure will be cleared each time plot is called
50+
51+
Widget attributes:
52+
-----------------
53+
figure: instance of matplotlib.figure.Figure
54+
axes: figure axes
55+
56+
Example:
57+
-------
58+
self.widget = MatplotlibWidget(self, yscale='log', hold=True)
59+
from numpy import linspace
60+
x = linspace(-10, 10)
61+
self.widget.axes.plot(x, x**2)
62+
self.wdiget.axes.plot(x, x**3)
63+
"""
64+
def __init__(self, parent=None, title='', xlabel='', ylabel='',
65+
xlim=None, ylim=None, xscale='linear', yscale='linear',
66+
width=4, height=3, dpi=100, hold=False):
67+
self.figure = Figure(figsize=(width, height), dpi=dpi)
68+
self.axes = self.figure.add_subplot(111)
69+
self.axes.set_title(title)
70+
self.axes.set_xlabel(xlabel)
71+
self.axes.set_ylabel(ylabel)
72+
if xscale is not None:
73+
self.axes.set_xscale(xscale)
74+
if yscale is not None:
75+
self.axes.set_yscale(yscale)
76+
if xlim is not None:
77+
self.axes.set_xlim(*xlim)
78+
if ylim is not None:
79+
self.axes.set_ylim(*ylim)
80+
self.axes.hold(hold)
81+
82+
Canvas.__init__(self, self.figure)
83+
self.setParent(parent)
84+
85+
Canvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
86+
Canvas.updateGeometry(self)
87+
88+
def sizeHint(self):
89+
w, h = self.get_width_height()
90+
return QSize(w, h)
91+
92+
def minimumSizeHint(self):
93+
return QSize(10, 10)
94+
95+
96+
97+
#===============================================================================
98+
# Example
99+
#===============================================================================
100+
if __name__ == '__main__':
101+
import sys
102+
from PyQt4.QtGui import QMainWindow, QApplication
103+
from numpy import linspace
104+
105+
class ApplicationWindow(QMainWindow):
106+
def __init__(self):
107+
QMainWindow.__init__(self)
108+
self.mplwidget = MatplotlibWidget(self, title='Example',
109+
xlabel='Linear scale',
110+
ylabel='Log scale',
111+
hold=True, yscale='log')
112+
self.mplwidget.setFocus()
113+
self.setCentralWidget(self.mplwidget)
114+
self.plot(self.mplwidget.axes)
115+
116+
def plot(self, axes):
117+
x = linspace(-10, 10)
118+
axes.plot(x, x**2)
119+
axes.plot(x, x**3)
120+
121+
app = QApplication(sys.argv)
122+
win = ApplicationWindow()
123+
win.show()
124+
sys.exit(app.exec_())

‎plugins/imageplotplugin.py

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright © 2009-2010 CEA
4+
# Pierre Raybaut
5+
# Licensed under the terms of the CECILL License
6+
# (see guiqwt/__init__.py for details)
7+
8+
"""
9+
imageplotplugin
10+
===============
11+
12+
A guiqwt image widget plugin for Qt Designer
13+
"""
14+
15+
from guiqwt.qtdesigner import create_qtdesigner_plugin
16+
Plugin = create_qtdesigner_plugin("guiqwt", "guiqwt.plot", "ImageWidget",
17+
icon="image.png")

‎plugins/matplotlibplugin.py

Copy file name to clipboard
+66Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright © 2009 Pierre Raybaut
4+
# Licensed under the terms of the MIT License
5+
6+
from PyQt4.QtGui import QIcon
7+
from PyQt4.QtDesigner import QPyDesignerCustomWidgetPlugin
8+
9+
import os
10+
from matplotlib import rcParams
11+
from matplotlibwidget import MatplotlibWidget
12+
13+
rcParams['font.size'] = 9
14+
15+
class MatplotlibPlugin(QPyDesignerCustomWidgetPlugin):
16+
def __init__(self, parent=None):
17+
QPyDesignerCustomWidgetPlugin.__init__(self)
18+
19+
self._initialized = False
20+
21+
def initialize(self, formEditor):
22+
if self._initialized:
23+
return
24+
25+
self._initialized = True
26+
27+
def isInitialized(self):
28+
return self._initialized
29+
30+
def createWidget(self, parent):
31+
return MatplotlibWidget(parent)
32+
33+
def name(self):
34+
return "MatplotlibWidget"
35+
36+
def group(self):
37+
return "Python(x,y)"
38+
39+
def icon(self):
40+
image = os.path.join(rcParams['datapath'], 'images', 'matplotlib.png')
41+
return QIcon(image)
42+
43+
def toolTip(self):
44+
return ""
45+
46+
def whatsThis(self):
47+
return ""
48+
49+
def isContainer(self):
50+
return False
51+
52+
def domXml(self):
53+
return '<widget class="MatplotlibWidget" name="mplwidget">\n' \
54+
'</widget>\n'
55+
56+
def includeFile(self):
57+
return "matplotlibwidget"
58+
59+
60+
if __name__ == '__main__':
61+
import sys
62+
from PyQt4.QtGui import QApplication
63+
app = QApplication(sys.argv)
64+
widget = MatplotlibWidget()
65+
widget.show()
66+
sys.exit(app.exec_())

‎plugins/plotplugin.py

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright © 2009-2010 CEA
4+
# Pierre Raybaut
5+
# Licensed under the terms of the CECILL License
6+
# (see guiqwt/__init__.py for details)
7+
8+
"""
9+
plotplugin
10+
==========
11+
12+
A guiqwt plot widget plugin for Qt Designer
13+
"""
14+
15+
from guiqwt.qtdesigner import create_qtdesigner_plugin
16+
Plugin = create_qtdesigner_plugin("guiqwt", "guiqwt.plot", "CurveWidget",
17+
icon="curve.png")

‎setup.py

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
"""PyQt Designer Plugins"""
3+
4+
from distutils.core import setup
5+
import os
6+
import os.path as osp
7+
8+
def get_data_files(dirname):
9+
"""Return data files in directory *dirname*"""
10+
flist = []
11+
for dirpath, _dirnames, filenames in os.walk(dirname):
12+
for fname in filenames:
13+
flist.append(osp.join(dirpath, fname))
14+
return flist
15+
16+
setup(name='PyQtdesignerplugins', version='1.0',
17+
description='PyQtdesignerplugins installs Qt Designer plugins for PyQt4',
18+
long_description="""PyQtdesignerplugins installs Python Qt designer plugins (Matplotlib, guiqwt, ...) in PyQt4 directory""",
19+
py_modules = ['matplotlibwidget'],
20+
data_files=[(r'Lib\site-packages\PyQt4\plugins\designer\python', get_data_files('plugins'))],
21+
requires=["PyQt4 (>4.3)",],
22+
author = "Pierre Raybaut",
23+
author_email = 'pierre.raybaut@gmail.com',
24+
url = 'http://code.google.com/p/winpython/',
25+
classifiers=['Operating System :: Microsoft :: Windows'])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.