def tuple_to_qfont(tup):
    """
    Create a QFont from tuple:
        (family [string], size [int], italic [bool], bold [bool])
    """
    if not (isinstance(tup, tuple) and len(tup) == 4
            and font_is_installed(tup[0]) and isinstance(tup[1], Integral)
            and isinstance(tup[2], bool) and isinstance(tup[3], bool)):
        return None
    font = QtGui.QFont()
    family, size, italic, bold = tup
    font.setFamily(family)
    font.setPointSize(size)
    font.setItalic(italic)
    font.setBold(bold)
    return font
Ejemplo n.º 2
0
 def initializeGUI(self):
     #Tooltips
     QtWidgets.QToolTip.setFont(QtGui.QFont('SansSerif', 14))
     self.setToolTip('IOC Measurement')
     #Toolbar
     self.addToolBar(NavigationToolbar(self.PyTrace_widget.PSensorPlot,self))
     #Menu
     mnuExit=QtWidgets.QAction('&End Program',self)
     mnuExit.setStatusTip('Exit PyTrace')
     mnuExit.triggered.connect(self.close)
     menu=self.menuBar()
     mnufile=menu.addMenu('P&yTrace')
     mnufile.addAction(mnuExit)
     # Resize main window
     self.resize(1100,1000)  # 1000, 850
     #self.center()
     self.setWindowTitle('PyTrace@ESS')
     self.show()       
Ejemplo n.º 3
0
 def __controls(self):
     #Quit Button
     self.btnQuit = QtWidgets.QPushButton('Quit', self)
     self.btnQuit.setToolTip('Quit from PyTrack')
     self.btnQuit.clicked.connect(self.parent.close)
     #Label stupida
     self.lblinfo = QtWidgets.QLabel(' ',self)
     self.lblinfo.setToolTip('http://esss.se')
     self.lblinfo.setPixmap(QtGui.QPixmap('ESS_Logo.png'))
     #Take a measurement
     self.btnStart = QtWidgets.QPushButton('Start',self)
     self.btnStart.clicked.connect(self.Start)
     self.btnStop = QtWidgets.QPushButton('Stop',self)
     self.btnStop.clicked.connect(self.Stop)
     #Label for Messages
     self.lblMessages=QtWidgets.QLabel('Press button to start',self)
     self.lblAuthors=QtWidgets.QLabel('MuYuan 2019\nSRF Section\nLinac Group\nAcceleration Division')
     self.lblAuthors.setAlignment(QtCore.Qt.AlignCenter)
     self.lblAuthors.setFont(QtGui.QFont('',10))
     #puts a canvas object here
     self.PSensorPlot=PSensorCanvas(self, width=5, height=3.5, dpi=144)
     self.PSensorPlot.setToolTip('IOC Measurement')
     #time message
     self.lblTimeMessages=QtWidgets.QLabel(time.strftime("%d-%m-%Y %H:%M:%S",time.localtime(time.time())),self)
     #other controls
     self.lblOperator=QtWidgets.QLabel('Operator',self)
     self.txtOperator=QtWidgets.QLineEdit(self)
     self.txtOperator.setText('SRF Team')
     self.txtOperator.setFixedWidth(100)
     self.lblLocation=QtWidgets.QLabel('Location',self)
     self.txtLocation=QtWidgets.QLineEdit(self)
     self.txtLocation.setText('SRF Laboratory')
     self.lblComments=QtWidgets.QLabel('Comments',self)
     self.txtComments=QtWidgets.QLineEdit(self)
     self.txtComments.setText('IOC waveform measurement')
     self.txtComments.setFixedWidth(300)
     self.lblScanInterval=QtWidgets.QLabel('Interval:',self)
     self.txtScanInterval=QtWidgets.QLineEdit(self)
     self.txtScanInterval.setText('1')
     self.txtScanInterval.setFixedWidth(40)
     self.lblUnit=QtWidgets.QLabel('s',self)
     self.btnInterval=QtWidgets.QPushButton('Apply',self)
     self.btnInterval.setEnabled(True)
     self.btnInterval.clicked.connect(self.setInterval)
    def _init_toolbar(self):
        self.basedir = str(cbook._get_data_path('images'))

        background_color = self.palette().color(self.backgroundRole())
        foreground_color = self.palette().color(self.foregroundRole())
        icon_color = (foreground_color
                      if background_color.value() < 128 else None)

        for text, tooltip_text, image_file, callback in self.toolitems:

            if callback not in [
                    'zoom', 'pan', 'back', 'forward', 'home',
                    'configure_subplots'
            ]:

                if text is None:
                    #self.addSeparator()
                    pass
                else:
                    a = self.addAction(QIcon('res\\save_icon.ico'), text,
                                       getattr(self, callback))
                    self._actions[callback] = a

                    if tooltip_text is not None:
                        a.setToolTip(tooltip_text)
                    if text == 'Subplots':
                        a = self.addAction(
                            self._icon("qt4_editor_options.png", icon_color),
                            'Customize', self.edit_parameters)
                        a.setToolTip('Edit axis, curve and image parameters')

        # Add the (x, y) location widget at the right side of the toolbar
        # The stretch factor is 1 which means any resizing of the toolbar
        # will resize this label instead of the buttons.
        self.measure_win_A = QtWidgets.QAction(QIcon("res\\m_icon.ico"),
                                               "Open Measurement Window", self)
        self.measure_win_A.triggered.connect(self.parent.Open_measure_window)
        self.addAction(self.measure_win_A)

        self.statusLabel = QtWidgets.QLabel("", self)
        self.statusLabel.setAlignment(QtCore.Qt.AlignHCenter
                                      | QtCore.Qt.AlignVCenter)

        self.statusLabel.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum,
                                  QtWidgets.QSizePolicy.Ignored))

        self.statusLabel.setStyleSheet("QLabel { color : red; }")
        self.statusLabelAction = self.addWidget(self.statusLabel)
        font1 = QtGui.QFont("Times", 12)
        self.statusLabelAction.setVisible(False)
        self.statusLabel.setFont(font1)

        if self.coordinates:
            self.locLabel = QtWidgets.QLabel("", self)
            self.locLabel.setAlignment(QtCore.Qt.AlignRight
                                       | QtCore.Qt.AlignVCenter)
            self.locLabel.setSizePolicy(
                QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                      QtWidgets.QSizePolicy.Ignored))
            self.coordinateLabel = self.addWidget(self.locLabel)
            newfont = QtGui.QFont("Times", 12)
            self.coordinateLabel.setVisible(True)
            self.locLabel.setFont(newfont)
Ejemplo n.º 5
0
    def __init__(self, algSettingsDict, parent=None):
        """"""
        QtWidgets.QDialog.__init__(self, parent)
        self.setWindowTitle('Change Algorithm-Specific Settings')
        self.setWindowIcon(QtGui.QIcon('kiwi.png'))
        self.setMinimumWidth(400)
        self.cur = algSettingsDict["current"]

        # Set the font to be used for section headings
        fnt = QtGui.QFont()
        fnt.setBold(True)

        # AF-MUSIC
        self.afTitle = QtWidgets.QLabel("AF-MUSIC:")
        self.afTitle.setFont(fnt)

        self.fmax_l = QtWidgets.QLabel(u"\u0192_max (Hz):")
        self.fmax = QtWidgets.QLineEdit(self)
        self.fmax.setText(str(algSettingsDict["AF-MUSIC"]["f_max"]))

        self.fmin_l = QtWidgets.QLabel(u"\u0192_min (Hz):")
        self.fmin = QtWidgets.QLineEdit(self)
        self.fmin.setText(str(algSettingsDict["AF-MUSIC"]["f_min"]))

        self.f0_l = QtWidgets.QLabel("Focusing Frequency (Hz):")
        self.f0 = QtWidgets.QLineEdit(self)
        self.f0.setText(str(algSettingsDict["AF-MUSIC"]["f_0"]))

        # GCC
        self.GCCTitle = QtWidgets.QLabel("GCC:")
        self.GCCTitle.setFont(fnt)

        # Available processors: PHAT, p-PHAT, CC, RIR, SCOT, HB
        self.GCC_l = QtWidgets.QLabel("Processor:")
        # self.GCC.setText(algSettingsDict["GCC"]["processor"])

        self.possible_processors = ["PHAT", "p-PHAT", "CC", "RIR", "SCOT", "HB"]
        self.cb = QtWidgets.QComboBox()
        self.cb.addItems(self.possible_processors)
        self.cb.setCurrentIndex(self.possible_processors.index(algSettingsDict["GCC"]["processor"]))


        self.def_rho = algSettingsDict["GCC"]["rho"]
        self.sl_l = QtWidgets.QLabel(u"0 \u2265 \u03C1={} \u2265 1:".format(self.def_rho))
        self.sl = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        self.sl.setMinimum(0)
        self.sl.setMaximum(100)
        self.sl.setTickInterval(10)
        self.sl.setTickPosition(QtWidgets.QSlider.TicksBelow)
        self.sl.setValue(int(self.def_rho*100))
        self.sl.valueChanged.connect(self.changeRho)

        # MUSIC
        self.MUSICTitle = QtWidgets.QLabel("MUSIC:")
        self.MUSICTitle.setFont(fnt)

        self.MUSIC_l = QtWidgets.QLabel("Frequency:")
        self.MUSIC = QtWidgets.QLineEdit(self)
        self.MUSIC.setText(str(algSettingsDict["MUSIC"]["freq"]))

        self.activate = QtWidgets.QPushButton("Set")

        Box = QtWidgets.QVBoxLayout()

        Box.addWidget(self.afTitle)
        f_min = QtWidgets.QHBoxLayout()
        f_min.addWidget(self.fmin_l)
        f_min.addWidget(self.fmin)
        Box.addLayout(f_min)

        f_max = QtWidgets.QHBoxLayout()
        f_max.addWidget(self.fmax_l)
        f_max.addWidget(self.fmax)
        Box.addLayout(f_max)

        f_0 = QtWidgets.QHBoxLayout()
        f_0.addWidget(self.f0_l)
        f_0.addWidget(self.f0)
        Box.addLayout(f_0)

        Box.addSpacerItem(QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum,
                                                QtWidgets.QSizePolicy.Expanding))

        Box.addWidget(self.GCCTitle)
        procBox = QtWidgets.QHBoxLayout()
        procBox.addWidget(self.GCC_l)
        procBox.addWidget(self.cb)
        Box.addLayout(procBox)

        rhoBox = QtWidgets.QHBoxLayout()
        rhoBox.addWidget(self.sl_l)
        rhoBox.addWidget(self.sl)
        Box.addLayout(rhoBox)

        Box.addSpacerItem(QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum,
                                                QtWidgets.QSizePolicy.Expanding))

        Box.addWidget(self.MUSICTitle)
        MUSICBox = QtWidgets.QHBoxLayout()
        MUSICBox.addWidget(self.MUSIC_l)
        MUSICBox.addWidget(self.MUSIC)
        Box.addLayout(MUSICBox)

        Box.addWidget(self.activate)

        # Now put everything into the frame
        self.setLayout(Box)