Beispiel #1
0
    def __init__(self):

        QtWidgets.QWidget.__init__(self)
        self.form = Ui_Form()
        self.form.setupUi(self)
        self.team = Team()
        self.form.teamWidgetLayout.addWidget(self.team)
        self.form.cancel_btn.clicked.connect(self.cancel)
        self.form.save_btn.clicked.connect(self.save)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Beispiel #2
0
    def __init__(self, prefix):
        QtGui.QMainWindow.__init__(self)
        self.prefix = prefix
        # setup the ui
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        # setup the button actions
        self.bActions = {
            self.ui.go: (self.go, "go"),
            self.ui.stop: (self.stop, "stop")
        }
        pre = os.path.dirname(sys.argv[0]) + "/button_"

        # and connect them
        for button, f, name in [(self.ui.go, self.go, "go"),
                                (self.ui.stop, self.stop, "stop")]:
            self.connect(button, QtCore.SIGNAL("clicked()"), f)
            pix = QPixmap(pre + name + ".png")
            button.releasedIcon = QIcon(pix)
            button.pressedIcon = QIcon(pre + name + "_down.png")
            button.setIcon(button.releasedIcon)
            button.setIconSize(pix.size())
            button.setMask(QRegion(pix.mask()).translated(8, 6))

            def pressedAction(button=button):
                button.setIcon(button.pressedIcon)

            button.pressedAction = pressedAction
            self.connect(button, QtCore.SIGNAL("pressed()"),
                         button.pressedAction)

            def releasedAction(button=button):
                button.setIcon(button.releasedIcon)

            button.releasedAction = releasedAction
            self.connect(button, QtCore.SIGNAL("released()"),
                         button.releasedAction)
        # setup the lineEdit actions
        self.lActions = {}
        for line, pv, pvrbv in \
                [ (self.ui.V,  self.prefix + ":MOTOR.VELO", self.prefix + ":MOTOR.VELO"),
                  (self.ui.TA, self.prefix + ":MOTOR.ACCL", self.prefix + ":MOTOR.ACCL"),
                  (self.ui.P,  self.prefix + ":P", self.prefix + ":P:RBV"),
                  (self.ui.I,  self.prefix + ":I", self.prefix + ":I:RBV")]:

            def f(string, self=self, pv=pv):
                caput(pv, float(string))
                self.computeTime()

            self.lActions[line] = f

            def monitor(value, self=self, line=line):
                if not line.isModified() or not line.hasFocus():
                    line.setText(str(value))
                self.computeTime()

            camonitor(pvrbv, monitor)
        # and connect them
        for line, f in self.lActions.items():
            self.connect(line, QtCore.SIGNAL("textChanged(const QString &) "),
                         f)
        # make a position plot
        playout = QtGui.QVBoxLayout(self.ui.pFrame)
        self.pPlot = plot(self.ui.pFrame)
        playout.addWidget(self.pPlot)
        self.pPlot.setAxisTitle(QwtPlot.xBottom, "Time (s)")
        self.pPlot.setAxisTitle(QwtPlot.yLeft, 'Position (mm)')
        self.pPlot.setAxisTitle(QwtPlot.yRight, "Position Error (mm)")
        # make a velocity plot
        vlayout = QtGui.QVBoxLayout(self.ui.vFrame)
        self.vPlot = plot(self.ui.vFrame)
        vlayout.addWidget(self.vPlot)
        self.vPlot.setAxisTitle(QwtPlot.xBottom, "Time (s)")
        self.vPlot.setAxisTitle(QwtPlot.yLeft, 'Velocity (mm/s)')
        # store the arrays
        self.arrays = {}
        # set some monitors on the array
        self.arrayFuncs = {}
        for i, pv in enumerate([
                self.prefix + ":GATHER:DEMANDPOSN",
                self.prefix + ":GATHER:POSN",
                self.prefix + ":GATHER:DEMANDVELO",
                self.prefix + ":GATHER:VELO", self.prefix + ":GATHER:FERR",
                self.prefix + ":GATHER:TIME"
        ]):

            def f(value, self=self, i=i):
                if i in (0, 1, 4):
                    factor = caget(self.prefix + ":MOTOR.MRES")
                elif i in (2, 3):
                    factor = 1000 * caget(self.prefix + ":MOTOR.MRES")
                else:
                    factor = 0.001
                if i == 4 and self.arrays.has_key(4) and max(
                        abs(self.arrays[4])) > 0.0:
                    # old following error
                    self.arrays[6] = self.arrays[4]
                self.arrays[i] = value * factor
                self.updateArray(i)

            self.arrayFuncs[pv] = f
        # plot some curves
        self.olderror = self.pPlot.makeCurve("Old Posn Error",
                                             y2=True,
                                             col=Qt.darkRed,
                                             width=1)
        self.curves = [
            self.pPlot.makeCurve("Demand Posn", col=Qt.darkBlue, width=3),
            self.pPlot.makeCurve("Actual Posn", col=Qt.green, width=1),
            self.vPlot.makeCurve("Demand Velocity", col=Qt.darkBlue, width=3),
            self.vPlot.makeCurve("Actual Velocity", col=Qt.green, width=1),
            self.pPlot.makeCurve("Posn Error", y2=True, col=Qt.red, width=2)
        ]
        for pv, f in self.arrayFuncs.items():
            camonitor(pv, f)
        # add tracking
        self.connect(Spy(self.pPlot.canvas()), QtCore.SIGNAL("MouseMove"),
                     self.showPCoordinates)
        self.connect(Spy(self.vPlot.canvas()), QtCore.SIGNAL("MouseMove"),
                     self.showVCoordinates)
        self.should_go = False
        # connect up the other buttons
        self.pPlot.autoscaleButton = QtGui.QPushButton(self.pPlot)
        self.pPlot.autoscaleButton.setText("Autoscale")
        self.pPlot.autoscaleButton.setCheckable(True)
        font = QtGui.QFont()
        font.setFamily("Sans Serif")
        font.setPointSize(10)
        self.pPlot.autoscaleButton.setFont(font)
        self.connect(self.ui.printScreen, QtCore.SIGNAL("clicked()"),
                     self.printScreen)
        self.connect(self.pPlot.autoscaleButton,
                     QtCore.SIGNAL("toggled(bool)"), self.pPlot.setAutoscale)
        self.connect(self.ui.defaults, QtCore.SIGNAL("clicked()"),
                     self.defaults)
        self.ui.D.setFocus()
        self.go_timer = QtCore.QTimer()
Beispiel #3
0
 def __init__(self):
     super(VigenereCipher, self).__init__()
     self.ui = Ui_Form()
     self.ui.setupUi(self)
     self.ui.encryptButton.clicked.connect(self.encryptSignal)
     self.ui.decryptButton.clicked.connect(self.decryptSignal)