Parcourir la source

Code Cleaning

Matze il y a 5 ans
Parent
commit
47a5de80b7

+ 2 - 61
KCG/base/backend/board/sequences.py

@@ -8,73 +8,14 @@ and will yield True or False depending on the result of the action performed
 import logging
 
 from . import *
-from .utils import *
 from .utils import get_board_config
 import json
 from PyQt4 import QtGui, QtCore
+from ...kcgwidget import PopupDialog
 import os
 
-def tr(_, x):
-    """
-    Dummy Translation method that does not translate
-    :param _: unused
-    :param x: the string to "translate"
-    :return: x
-    """
-    return x
 
 
-
-class PopupDialog(QtGui.QDialog):
-    """
-    Simple Class to show a popup dialog.
-    """
-
-    def __init__(self, text, title=None, parent=None):
-        QtGui.QDialog.__init__(self, parent)
-        self.text = text
-        self.setWindowTitle(title if title else tr("Dialog", "User action required"))
-        self.return_value = False
-
-        size = QtCore.QSize(200, 200)
-        # self.setMaximumSize(size)
-        self.setMinimumSize(size)
-        box = QtGui.QVBoxLayout()
-        self.text_label = QtGui.QLabel(self.text)
-        self.text_label.setAlignment(QtCore.Qt.AlignCenter)
-        box.addWidget(self.text_label)
-        self.okay_btn = QtGui.QPushButton(tr("Button", "Ok"))
-        self.okay_btn.setStyleSheet("padding: 15px;")
-        self.okay_btn.clicked.connect(self.on_okay)
-        box.addWidget(self.okay_btn)
-        box.addSpacerItem(QtGui.QSpacerItem(1, 20))
-        self.cancel_btn = QtGui.QPushButton(tr("Button", "Cancel"))
-        self.cancel_btn.setStyleSheet("padding: 15px;")
-        self.cancel_btn.clicked.connect(self.on_cancel)
-        box.addWidget(self.cancel_btn)
-        self.setLayout(box)
-
-    def on_okay(self):
-        """
-        Handler for the press of the ok button
-        """
-        self.return_value = True
-        self.close()
-
-    def on_cancel(self):
-        """
-        Handler for the press of the cancel button
-        :return:
-        """
-        self.close()
-
-    def get_return_value(self):
-        """
-        Get True if the Window was closed with OK else False
-        :return: True if OK else False
-        """
-        return self.return_value
-
 def read_sequence(board_version):
     #print("sequence ",board_version)
     filename = os.path.join(os.path.dirname(__file__), "sequences", "sequences_" + str(board_version)+".json")
@@ -99,7 +40,7 @@ def run_sequence(board_id, sequence, progressbar=None):
         
         if entry[2] != "":
             # Dialog
-            dialog = PopupDialog(tr("Button", "{0} (on board {1})".format(entry[2], board_id)))
+            dialog = PopupDialog("{0} (on board {1})".format(entry[2], board_id))
             dialog.exec_()
             dialog.deleteLater()
 

+ 2 - 52
KCG/base/backendinterface.py

@@ -74,10 +74,10 @@ def _bif_continuous_read_is_enabled(board_id, popup_title_text=None):
     """
     if board.get_board_status(board_id).continuous_read:
         if not available_boards.multi_board:
-            popup = PopupDialog(tr("Dialog", "Continuous read is currently active!\nStop continuous read and proceed?"),
+            popup = kcgw.PopupDialog(tr("Dialog", "Continuous read is currently active!\nStop continuous read and proceed?"),
                                 title=popup_title_text)
         else:
-            popup = PopupDialog(tr("Dialog", "Board {board_id}\nContinuous read is currently active!\nStop continuous read and proceed?").format(board_id=board_id),
+            popup = kcgw.PopupDialog(tr("Dialog", "Board {board_id}\nContinuous read is currently active!\nStop continuous read and proceed?").format(board_id=board_id),
                                 title=popup_title_text)
         popup.exec_()
         popup.deleteLater()
@@ -136,56 +136,6 @@ def _bif_status_readout(board_id):
 backup_readout = bk_status_readout
 
 
-class PopupDialog(QtGui.QDialog):
-    """
-    Simple Class to show a popup dialog.
-    """
-
-    def __init__(self, text, title=None, parent=None):
-        QtGui.QDialog.__init__(self, parent)
-        self.text = text
-        self.setWindowTitle(title if title else tr("Dialog", "User action required"))
-        self.return_value = False
-
-        size = QtCore.QSize(200, 200)
-        # self.setMaximumSize(size)
-        self.setMinimumSize(size)
-        box = QtGui.QVBoxLayout()
-        self.text_label = QtGui.QLabel(self.text)
-        self.text_label.setAlignment(QtCore.Qt.AlignCenter)
-        box.addWidget(self.text_label)
-        self.okay_btn = QtGui.QPushButton(tr("Button", "Ok"))
-        self.okay_btn.setStyleSheet("padding: 15px;")
-        self.okay_btn.clicked.connect(self.on_okay)
-        box.addWidget(self.okay_btn)
-        box.addSpacerItem(QtGui.QSpacerItem(1, 20))
-        self.cancel_btn = QtGui.QPushButton(tr("Button", "Cancel"))
-        self.cancel_btn.setStyleSheet("padding: 15px;")
-        self.cancel_btn.clicked.connect(self.on_cancel)
-        box.addWidget(self.cancel_btn)
-        self.setLayout(box)
-
-    def on_okay(self):
-        """
-        Handler for the press of the ok button
-        """
-        self.return_value = True
-        self.close()
-
-    def on_cancel(self):
-        """
-        Handler for the press of the cancel button
-        :return:
-        """
-        self.close()
-
-    def get_return_value(self):
-        """
-        Get True if the Window was closed with OK else False
-        :return: True if OK else False
-        """
-        return self.return_value
-
 
 
 class _bif_ProgressBar(QtGui.QProgressBar):

+ 7 - 6
KCG/widgets/timescan_widget.py

@@ -497,7 +497,7 @@ class timingPlotWidget(kcgw.KCGWidgets):
 #
 
 class AutomationThread(QtCore.QObject):
-    '''Timescan Thread class'''
+    '''Automation Thread class'''
     updateSignal = QtCore.pyqtSignal(int)
     stopSignal = QtCore.pyqtSignal()
     startScan  = QtCore.pyqtSignal()
@@ -546,8 +546,6 @@ class AutomationThread(QtCore.QObject):
 
 from ..extensions import deltaPower
 class Automation(kcgw.KCGWidgets):
-    
-
     def __init__(self, layout, startScan, info, abortScan):
         super(Automation, self).__init__()
         self.layout = layout
@@ -599,6 +597,7 @@ class Automation(kcgw.KCGWidgets):
         lineindex += 1
 
         self.tst = None
+        
     def connect(self):
         try:
             self.power = deltaPower.DeltaPower(str(self.input.text()))
@@ -844,11 +843,13 @@ class TimeScanWidget(kcgw.KCGWidgets):
         lineindex += 1
         
 
+        ###########################################################
+        ### Automation
         self.automationLayout = QtGui.QGridLayout()
-
         self.outerLayout.addLayout(self.automationLayout)
-     
-        self.auto = Automation(self.automationLayout, self.startScan, self.input, self.abort)     
+        self.auto = Automation(self.automationLayout, self.startScan, self.input, self.abort)  
+        ###########################################################
+
         self.outerLayout.addStretch(1)
         self.adjustSize()
         #self.layout.addStretch(1)