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