some general GUI improvements & code cleanups

Thu, 14 Feb 2008 19:28:41 +0100

author
David Douard <david.douard@logilab.fr>
date
Thu, 14 Feb 2008 19:28:41 +0100
changeset 48
ceb2a3a4de6c
parent 47
0ebdbcbb7852
child 49
a682ee5e6a55

some general GUI improvements & code cleanups

pygpibtoolkit/HP3562A/mathtools.py file | annotate | diff | comparison | revisions
pygpibtoolkit/HP3562A/q3562A.py file | annotate | diff | comparison | revisions
--- a/pygpibtoolkit/HP3562A/mathtools.py	Thu Feb 14 19:28:10 2008 +0100
+++ b/pygpibtoolkit/HP3562A/mathtools.py	Thu Feb 14 19:28:41 2008 +0100
@@ -48,7 +48,6 @@
     fmax = spectrum.argmax()
     w = int(fmax/10) # argh
     vmax = spectrum[fmax-w:fmax+w].sum()
-    print  spectrum[fmax-w],  spectrum[fmax], spectrum[fmax+w]
     thd = (spectrum.sum()-vmax)/(vmax)
     if db:
         thd = 10*numpy.log10(thd)
--- a/pygpibtoolkit/HP3562A/q3562A.py	Thu Feb 14 19:28:10 2008 +0100
+++ b/pygpibtoolkit/HP3562A/q3562A.py	Thu Feb 14 19:28:41 2008 +0100
@@ -54,6 +54,8 @@
         self.connect(self.windowMapper, QtCore.SIGNAL("mapped(QWidget *)"),
                      self.workspace, QtCore.SLOT("setActiveWindow(QWidget *)"))
         
+        self._receiving = False
+        
         self.createActions()
         self.createMenus()
         self.createToolBars()
@@ -144,14 +146,17 @@
 
 
         self.getStateAct = QtGui.QAction(self.tr("Get state"), self)
+        self.getStateAct.setCheckable(True)
         self.getStateAct.setStatusTip(self.tr("Retrieve State from GPIB device"))
         self.connect(self.getStateAct, QtCore.SIGNAL("triggered()"),
                      self.getState)
         self.getTraceAct = QtGui.QAction(self.tr("Get trace"), self)
+        self.getTraceAct.setCheckable(True)
         self.getTraceAct.setStatusTip(self.tr("Retrieve Trace from GPIB device"))
         self.connect(self.getTraceAct, QtCore.SIGNAL("triggered()"),
                      self.getTrace)
         self.getCoordAct = QtGui.QAction(self.tr("Get coord"), self)
+        self.getCoordAct.setCheckable(True)
         self.getCoordAct.setStatusTip(self.tr("Retrieve Coord from GPIB device"))
         self.connect(self.getCoordAct, QtCore.SIGNAL("triggered()"),
                      self.getCoord)
@@ -243,6 +248,7 @@
         
     def createToolBars(self):
         self.fileToolBar = self.addToolBar(self.tr("File"))
+        self.fileToolBar.setObjectName('filetoolbar')
         self.fileToolBar.addAction(self.openAct)
         self.fileToolBar.addAction(self.saveAsAct)
         self.fileToolBar.addSeparator()
@@ -311,7 +317,6 @@
                          self.datablockReceived)
             self.captureThread.start()
         except Exception, e:
-            print e
             self.gpib_plotter = None
 
     def datablockReceived(self, datablock):
@@ -321,14 +326,34 @@
         child = child_cls(datablock)
         self.workspace.addWindow(child)
         child.show()
+        self.getStateAct.setChecked(False)
+        self.getTraceAct.setChecked(False)
+        self.getCoordAct.setChecked(False)
+        self.statusBar().showMessage(self.tr("Received data block"), 2000)
+        self._receiving = False
 
     def getState(self):
+        if self._receiving:
+            return
+        self._receiving = True        
+        self.statusBar().showMessage(self.tr("Waiting for a %1 data block").arg(self.tr('state')))
+        self.getStateAct.setChecked(True)
         self.captureThread.startCapture(mode="state")
         
     def getTrace(self):
+        if self._receiving:
+            return
+        self._receiving = True        
+        self.statusBar().showMessage(self.tr("Waiting for a %1 data block").arg(self.tr('trace')))
+        self.getTraceAct.setChecked(True)
         self.captureThread.startCapture(mode="trace")
 
     def getCoord(self):
+        if self._receiving:
+            return
+        self._receiving = True        
+        self.statusBar().showMessage(self.tr("Waiting for a %1 data block").arg(self.tr('coord')))
+        self.getCoordAct.setChecked(True)
         self.captureThread.startCapture(mode="coord")
 
 class GPIBReceiver(QtCore.QThread):

mercurial