Browse Source

Timescan Maximised Window Bug Fix

Fixes #15
Minor bug Fixes
Patrick Schreiber 8 năm trước cách đây
mục cha
commit
efeceab6b5
5 tập tin đã thay đổi với 29 bổ sung48 xóa
  1. 2 36
      base/controlwidget.py
  2. 1 0
      base/kcg.py
  3. 6 4
      base/log.py
  4. 2 1
      config.py
  5. 18 7
      widgets/timingWidget.py

+ 2 - 36
base/controlwidget.py

@@ -117,21 +117,12 @@ class StatusLED(QtGui.QWidget):
     def set_tri(self):
         """ See set_tri of LED Class """
         self.led.set_tri()
-    # def toggle(self):
-    #     """ Toggle the LED """
-    #     if self.led.status:
-    #         self.led.set_off()
-    #     elif self.led.status == False:
-    #         self.led.set_on()
-    #     else:
-    #         self.led.set_on()
 
 class LogHandler(logging.Handler):
     def __init__(self, log_area):
         logging.Handler.__init__(self)
         self.text_area = log_area
         self.setFormatter(logging.Formatter('%(asctime)s: %(message)s'))
-        # log_handler.setFormatter(logging.Formatter('%(asctime)s - %(funcName)s(): %(message)s'))
 
     def emit(self, record):
         self.text_area.append(self.format(record))
@@ -153,30 +144,6 @@ class ControlWidget(kcgw.KCGWidgets):
         self.overlayout.addLayout(self.layout)
         self.overlayout.addStretch(1)
 
-        # ----------[ Toolbar ]-------------
-        # self.toolbar = QtGui.QToolBar()
-        # self.start_action = QtGui.QAction(QtGui.QIcon("icons/green/media-play.svg"), "Start", self)
-        # self.calibrate_action = QtGui.QAction(QtGui.QIcon("icons/orange/cog.svg"), "Calibrate", self)
-        # self.sync_action = QtGui.QAction(QtGui.QIcon("icons/green/loop-circular.svg"), "Syncronize", self)
-        # self.default_action = QtGui.QAction(QtGui.QIcon("icons/orange/box.svg"), "Set Defaults", self)
-        # self.reset_action = QtGui.QAction(QtGui.QIcon("icons/red/restore.svg"), "Soft Reset", self)
-        # self.stop_action = QtGui.QAction(QtGui.QIcon("icons/red/power-standby.svg"), "Board Off", self)
-        #
-        # self.toolbar.addActions([self.start_action,
-        #                          self.calibrate_action,
-        #                          self.sync_action,
-        #                          self.default_action,
-        #                          self.reset_action,
-        #                          self.stop_action])
-        # self.toolbar.insertSeparator(self.calibrate_action)
-        # self.toolbar.insertSeparator(self.stop_action)
-        # ----------[ End Toolbar ]------------
-
-        # self.overlayout.insertWidget(0, self.toolbar)
-        # self.overlayout.insertSpacing(1, 10)
-
-
-
         self.gridLayout = QtGui.QGridLayout()
         self.gridLayout.addWidget(self.createLabel(tr("Label", "Board Control")), 0, 0)
         self.gridLayout.addWidget(self.createLabel(tr("Label", "Detailed Board Control")), 2, 0)
@@ -313,6 +280,5 @@ class ControlWidget(kcgw.KCGWidgets):
                 self.pll_ld_led.set_on()
 
         except IndexError:
-            QtGui.QMessageBox.critical(self, "Status Update Error", "Not enough registers give for status update.")
-            return
-
+            QtGui.QMessageBox.critical(self, "Status Update Error", "Not enough registers given for status update.")
+            return

+ 1 - 0
base/kcg.py

@@ -17,6 +17,7 @@ from multipage import MultiPage
 import bitsTable as bt
 from base import log
 # ---------[ Widgets IMPORTANT!!! ]------------------
+# this enables widgets. If this is not imported (even though it is not directly used) no widgets will be available
 from widgets import *
 # from widgets import *  # copy in case the above line gets removed by ide
 # ---------[ IMPORTANT ]---------------------

+ 6 - 4
base/log.py

@@ -23,10 +23,12 @@ except epics.ca.ChannelAccessException as e:
         logging.error("Epics CA DLL not found")
 # ---[ Test if epics is acessible ]------
 # before = datetime.datetime.now()
-if epics.caget(config.epics_test_pv) == None:
-    noepics = True
-    epics_reachable = False
-    logging.error("Epics is not accessible (Timeout)")
+if not noepics:
+    if epics.caget(config.epics_test_pv) == None:
+        noepics = True
+        epics_reachable = False
+        logging.error("Epics is not accessible (Timeout)")
+
 
 # after = datetime.datetime.now()
 # if (after-before).total_seconds() > 3.0:

+ 2 - 1
config.py

@@ -119,7 +119,8 @@ guiIcon = "icons/KCG_Logo_r.png"
 # possible values:
 # Whatever you want (means default Qt Style)
 # blue - Blue style, has some bugs
-style = 'blue'
+# style = 'blue'
+style = 'default'
 # -------------------------------------------
 # ------------[ End Look and Feel ]--------------
 # -------------------------------------------

+ 18 - 7
widgets/timingWidget.py

@@ -301,11 +301,11 @@ class timingWidget(kcgw.KCGWidgets):
         self.layout = QtGui.QGridLayout()
         self.outerLayout = QtGui.QVBoxLayout()
         self.outerLayout.addLayout(self.layout)
-        self.outerLayout.addStretch(1)
         self.setLayout(self.outerLayout)
         self.time_scan_enabled = False
 
         # --------[ Create TimeScan part ]----------
+
         self.coarse_scan_range_label = self.createLabel(tr("Label", "Coarse scan range"))
         self.fine_scan_range_label = self.createLabel(tr("Label", "Fine scan range"))
         self.coarse_scan_min_spinbox = self.createSpinbox(0, bif.bk_get_config('th_delay_max'), start_value=0)
@@ -316,8 +316,7 @@ class timingWidget(kcgw.KCGWidgets):
         self.time_scan_button = self.createButton(tr("Button", "Start time scan"), connect=self.time_scan)
         Elements.addButton("start_time_scan", self.time_scan_button)
         self.timeScan = QtGui.QWidget()
-        self.outerLayout.addWidget(self.timeScan)
-        self.timeScan.hide()
+
         self.timeScanVLayout = QtGui.QVBoxLayout()
         self.timeScanLayout = QtGui.QGridLayout()
         self.timeScanVLayout.addWidget(self.time_scan_progressbar)
@@ -331,7 +330,11 @@ class timingWidget(kcgw.KCGWidgets):
         self.timeScanLayout.addWidget(self.fine_scan_max_spinbox, 3, 1)
         self.timeScanLayout.addWidget(self.time_scan_button, 4, 0)
         self.setTabOrder(self.fine_scan_max_spinbox, self.time_scan_button)
-        # --------[ Create Labels and corresponding Fields ]---------
+
+        #  --------[ End Time Scan Part ]-------------
+
+        #  --------[ Create Labels and corresponding Fields ]---------
+
         def update_delay(which, spinbox):
             board.config.update(which, getattr(self, spinbox).value())
         self.thdelayLabel = self.createLabel(tr("Label", "T/H Delay"))
@@ -427,6 +430,12 @@ class timingWidget(kcgw.KCGWidgets):
         self.layout.addWidget(self.totalAdc4Box, 4, 4)
         self.layout.addWidget(self.toggleTimeScanCheckbox, 5, 0)
 
+        #  -------[ Add TimeScan ]---------
+        self.outerLayout.addWidget(self.timeScan)
+        self.timeScan.hide()
+        self.outerLayout.addStretch(1)
+        #  -------[ End ]-----------
+
         #  ------[ Exclude Total Delay Boxes from Tab Order ]--------
         self.totalAdc1Box.setFocusPolicy(QtCore.Qt.ClickFocus)
         self.totalAdc2Box.setFocusPolicy(QtCore.Qt.ClickFocus)
@@ -444,12 +453,14 @@ class timingWidget(kcgw.KCGWidgets):
 
     def showTimeScan(self):
         if self.timeScan.isHidden():
+            # self.outerLayout.addWidget(self.timeScan)
             self.timeScan.show()
-            # self.parent().resize(self.outerLayout.minimumSize())
-            self.parent().resize(self.minimumSizeHint()*1.2)
         else:
             self.timeScan.hide()
-            # self.parent().resize(self.outerLayout.minimumSize())
+            # self.outerLayout.removeWidget(self.timeScan)
+        if self.parent().windowState() & QtCore.Qt.WindowMaximized:
+            self.parent().setWindowState(QtCore.Qt.WindowMaximized)
+        else:
             self.parent().resize(self.minimumSizeHint()*1.2)
 
     def time_scan(self):