qgpib_plotter.py

Wed, 16 Jan 2008 01:21:06 +0100

author
David Douard <david.douard@logilab.fr>
date
Wed, 16 Jan 2008 01:21:06 +0100
changeset 24
44866ca03611
parent 23
cb97962a1ae9
child 25
32d0d1cd44c3
permissions
-rw-r--r--

add some example hpgl files

22
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
1 #
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
2
23
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
3 import os, sys
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
4
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
5 from PyQt4 import QtGui, QtCore, uic
22
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
6 from PyQt4.QtCore import SIGNAL, Qt
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
7
23
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
8 from gpib_plotter import GPIBplotter
22
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
9 from hpgl_qt import QHPGLPlotterWidget
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
10
23
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
11 form_class, base_class = uic.loadUiType(os.path.join(os.path.dirname(__file__), "qhpgl_plotter.ui"))
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
12
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
13 from qpreferences import PreferenceItem, AbstractPreferences, PreferencesEditor
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
14
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
15 class Preferences(AbstractPreferences):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
16 ORGANISATION="Logilab"
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
17 APPLICATION="qgpib_plotter"
22
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
18
23
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
19 device = PreferenceItem('/dev/ttyUSB0', name=u'device', description=u'GPIB device')
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
20 address = PreferenceItem(5, name=u'GPIB address')
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
21 _pos = PreferenceItem(basetype=QtCore.QPoint)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
22 _size = PreferenceItem(basetype=QtCore.QSize)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
23 _appState = PreferenceItem(basetype=QtCore.QByteArray)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
24
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
25 class QtHPGLPlotter(QtGui.QMainWindow, form_class):
22
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
26 def __init__(self, parent=None):
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
27 QtGui.QMainWindow.__init__(self, parent)
23
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
28 self._plots = {}
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
29 self._prefs = Preferences()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
30 self.setupUi()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
31 self.initializeGPIB()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
32 if self._prefs._pos:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
33 self.move(self._prefs._pos)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
34 if self._prefs._size:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
35 self.resize(self._prefs._size)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
36 if self._prefs._appState:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
37 self.restoreState(self._prefs._appState)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
38
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
39 def setupUi(self):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
40 form_class.setupUi(self, self) # call qtdesigner generated form creation
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
41 # actions defined in designer
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
42 self.connect(self.actionPreferences, SIGNAL('triggered(bool)'),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
43 self.preferencesTriggered)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
44 self.connect(self.actionQuit, SIGNAL('triggered(bool)'),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
45 self.quitTriggered)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
46 self.connect(self.actionOpen, SIGNAL('triggered(bool)'),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
47 self.openTriggered)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
48 self.connect(self.actionSave, SIGNAL('triggered(bool)'),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
49 self.saveTriggered)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
50 self.connect(self.actionSaveAs, SIGNAL('triggered(bool)'),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
51 self.saveAsTriggered)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
52
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
53 self.plotterWidget = QHPGLPlotterWidget(self)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
54 self.setCentralWidget(self.plotterWidget)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
55
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
56 self.connect(self.captureButton, SIGNAL("toggled(bool)"),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
57 self.captureToggled)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
58
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
59 self._plots_list = QtGui.QStringListModel()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
60 self.plotsView.setModel(self._plots_list)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
61 self.connect(self.plotsView, SIGNAL('activated(const QModelIndex&)'),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
62 self.currentPlotChanged)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
63 self.connect(self.plotsView.selectionModel(),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
64 SIGNAL('currentChanged(const QModelIndex&, const QModelIndex&)'),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
65 self.currentPlotChanged)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
66
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
67 def currentPlotChanged(self, index, old_index=None):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
68 if index.isValid():
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
69 value = unicode(self.plotsView.model().data(index, Qt.DisplayRole).toString())
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
70
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
71 #self.plotterWidget = QHPGLPlotterWidget(self)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
72 #self.setCentralWidget(self.plotterWidget)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
73 self.plotterWidget.clear()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
74 self.plotterWidget.parse(self._plots[value])
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
75
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
76 def preferencesTriggered(self, checked=False):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
77 PreferencesEditor(self._prefs, self).exec_()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
78
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
79 def quitTriggered(self, checked=False):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
80 self.close()
22
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
81
23
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
82 def closeEvent(self, event):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
83 if 1:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
84 #if self.promptForSave():
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
85 self._prefs._pos = self.pos()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
86 self._prefs._size = self.size()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
87 self._prefs._appState = self.saveState()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
88 event.accept()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
89 else:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
90 event.ignore()
22
b2f4646161be Begin of a HPGL plotter application (PyQt4)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
91
23
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
92 def openTriggered(self, checked=False):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
93 filenames = QtGui.QFileDialog.getOpenFileNames(self, "Open a HPGL file to display", '.', 'HPGL files (*.plt)\nAll files (*)')
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
94 for filename in filenames:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
95 filename = str(filename)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
96 if os.path.exists(filename):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
97 data = open(filename).read()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
98 name = os.path.basename(filename)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
99 name = os.path.splitext(name)[0]
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
100 lst = self.plotsView.model().stringList()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
101 lst.append(name)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
102 self._plots[name] = data
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
103 self.plotsView.model().setStringList(lst)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
104 #self.plotsView.setCurrentIndex(self.plotsView.model().index(self.plotsView.model().stringList().count(), 0))
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
105
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
106
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
107
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
108 def saveTriggered(self, checked=False):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
109 print "save"
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
110 def saveAsTriggered(self, checked=False):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
111 print "saveAs"
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
112
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
113 def initializeGPIB(self):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
114 try:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
115 self.gpib_plotter = GPIBplotter(device=self._prefs.device,
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
116 address=self._prefs.address,
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
117 )
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
118 except:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
119 self.gpib_plotter = None
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
120 self._online = False
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
121 self.setCaptureLed()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
122
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
123 def captureToggled(self, state):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
124 if state:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
125 if self.gpib_plotter is None:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
126 self.initializeGPIB()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
127 if self.gpib_plotter is None:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
128 QtGui.QMessageBox.critical(self, self.tr("GPIB error"),
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
129 self.tr("<b>Unable to initialize GPIB connection</b>.<br>Please check your GPIB dongle and settings."))
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
130 self._online = False
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
131 else:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
132 # todo
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
133 self._online = True
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
134 else:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
135 self._online = False
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
136 self.setCaptureLed()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
137
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
138
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
139 def setCaptureLed(self):
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
140 if self._online:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
141 icn = QtGui.QIcon(':/icons/led_green.png')
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
142 else:
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
143 icn = QtGui.QIcon(':/icons/led_green_off.png')
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
144 self.captureButton.setIcon(icn)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
145 self.captureButton.setChecked(self._online)
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
146
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
147 if __name__ == '__main__':
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
148 a = QtGui.QApplication([])
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
149 w = QtHPGLPlotter()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
150 w.show()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
151 a.exec_()
cb97962a1ae9 make qplotter a working app: can new load several hpgl files à display them; have a preference system
David Douard <david.douard@logilab.fr>
parents: 22
diff changeset
152

mercurial