Exemplo n.º 1
0
 def loadPositiveInteger(self, font, src, dst):
     value = getattr(font.info, src)
     if value is not None:
         value = str(value)
     else:
         value = ""
     setattr(self, dst + "Edit", QLineEdit(value, self))
     validator = QIntValidator(self)
     validator.setBottom(0)
     getattr(self, dst + "Edit").setValidator(validator)
Exemplo n.º 2
0
    def __init__(self, data, parent=None):
        super(QtWidgets.QWidget, self).__init__(parent)
        self.setupUi(self)
        self.contacts = data

        self.labelNumFrames.setText(str(len(self.contacts[0].scoreArray)))
        self.labelTotalContacts.setText(str(len(self.contacts)))
        self.labelMeanScore.setText(str(mean_score_of_contactArray(self.contacts)))
        self.labelMedianScore.setText(str(median_score_of_contactArray(self.contacts)))
        self.savePlotButton.clicked.connect(self.savePlot)
        self.plotButton.clicked.connect(self.plotAttribute)

        posIntValidator = QIntValidator()
        posIntValidator.setBottom(3)
        self.smoothStrideField.setValidator(posIntValidator)

        self.contactPlotter = ContactPlotter(None, width=4, height=2, dpi=70)
        self.contactPlotter.plot_all_contacts_figure(self.contacts, 0)
        self.plotGridLayout.addWidget(self.contactPlotter)
Exemplo n.º 3
0
	def __init__(self, parent=None):
		super(lineEditDemo, self).__init__(parent)
		self.setWindowTitle("QLineEdit例子")

		flo = QFormLayout()
		pIntLineEdit  = QLineEdit( )
		pDoubleLineEdit  = QLineEdit()
		pValidatorLineEdit  = QLineEdit( )

		flo.addRow("整形", pIntLineEdit)
		flo.addRow("浮点型", pDoubleLineEdit)
		flo.addRow("字母和数字", pValidatorLineEdit)
        
		pIntLineEdit.setPlaceholderText("整形");
		pDoubleLineEdit.setPlaceholderText("浮点型");
		pValidatorLineEdit.setPlaceholderText("字母和数字");

		# 整形 范围:[1, 99]
		pIntValidator = QIntValidator(self)
		pIntValidator.setRange(1, 99)

		# 浮点型 范围:[-360, 360] 精度:小数点后2位
		pDoubleValidator = QDoubleValidator(self)
		pDoubleValidator.setRange(-360, 360)
		pDoubleValidator.setNotation(QDoubleValidator.StandardNotation)
		pDoubleValidator.setDecimals(2)
		
		# 字符和数字
		reg = QRegExp("[a-zA-Z0-9]+$")
		pValidator = QRegExpValidator(self)
		pValidator.setRegExp(reg)	

        # 设置验证器
		pIntLineEdit.setValidator(pIntValidator)
		pDoubleLineEdit.setValidator(pDoubleValidator)
		pValidatorLineEdit.setValidator(pValidator)
		                    
		self.setLayout(flo)                        
Exemplo n.º 4
0
 def createFormGroupBox(self):
     self.formGroupBox = QGroupBox('Label form')
     self.lid = QLineEdit()
     self.lid.setValidator(QIntValidator())
     self.label = QLineEdit()
     self.shortcut = QKeySequenceEdit()
     self.group = QLineEdit()
     self.pred_incomp = QLineEdit()
     layout = QFormLayout()
     layout.addRow(QLabel('id:'), self.lid)
     layout.addRow(QLabel('label:'), self.label)
     layout.addRow(QLabel('shortcut:'), self.shortcut)
     layout.addRow(QLabel('group:'), self.group)
     layout.addRow(QLabel('pred incompatibilities:'), self.pred_incomp)
     self.formGroupBox.setLayout(layout)
Exemplo n.º 5
0
 def _connect_line_edit(self):
     double_valid = QDoubleValidator()
     double_valid.setBottom(0.)
     for line_edit in self.findChildren(QLineEdit):
         line_name = line_edit.objectName()
         if line_name == "max_pwm_lbl":
             int_valid = QIntValidator()
             int_valid.setBottom(1)
             line_edit.setValidator(int_valid)
         else:
             line_edit.setValidator(double_valid)
         if line_name.startswith("in_moment"):
             i = int(line_name[-2])
             j = int(line_name[-1])
             in_moment_valid = QDoubleValidator()
             if i == j:
                 in_moment_valid.setBottom(0.)
                 line_edit.setValidator(in_moment_valid)
             else:
                 line_edit.setValidator(in_moment_valid)
             line_edit.textEdited.connect(self._change_in_moment)
         else:
             line_edit.textEdited.connect(self._change_engine)
     return
Exemplo n.º 6
0
    def configFrame(self):

        self.frame.virtualWorld = self.world

        # Init the table of inputs widget
        self.frame.tblWdgt_trainingList.setColumnCount(3)
        self.frame.tblWdgt_trainingList.setHorizontalHeaderLabels(
            ['Frase', 'Accion', 'Argumento'])
        self.frame.tblWdgt_trainingList.horizontalHeader(
        ).setStretchLastSection(True)

        self.frame.lnEdt_iterations.setValidator(
            QIntValidator(0, 1000, self.frame))

        self.initEvents()
Exemplo n.º 7
0
    def setupUi(self, MainWindow):
        MainWindow.resize(450, 240)
        MainWindow.setWindowTitle("Add Information")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        MainWindow.setCentralWidget(self.centralwidget)

        self.labelFood = QtWidgets.QLabel(self.centralwidget)
        self.labelFood.setGeometry(QtCore.QRect(10, 30, 100, 13))
        self.labelFood.setText("Food")

        self.labelCalories = QtWidgets.QLabel(self.centralwidget)
        self.labelCalories.setGeometry(QtCore.QRect(10, 80, 100, 13))
        self.labelCalories.setText("Calories")

        self.labelGrams = QtWidgets.QLabel(self.centralwidget)
        self.labelGrams.setGeometry(QtCore.QRect(10, 130, 100, 13))
        self.labelGrams.setText("Grams")

        self.lineEditFood = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEditFood.setGeometry(QtCore.QRect(10, 50, 411, 20))

        self.lineEditCalories = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEditCalories.setGeometry(QtCore.QRect(10, 100, 411, 20))
        self.onlyInt = QIntValidator()
        self.lineEditCalories.setValidator(self.onlyInt)

        self.lineEditGrams = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEditGrams.setGeometry(QtCore.QRect(10, 150, 411, 20))
        self.onlyInt = QIntValidator()
        self.lineEditGrams.setValidator(self.onlyInt)

        self.addButton = QtWidgets.QPushButton(self.centralwidget)
        self.addButton.setGeometry(QtCore.QRect(10, 200, 75, 23))
        self.addButton.setText("Add")

        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Exemplo n.º 8
0
    def _set_validators(self):
        # Set up the validators (could be in separate function or module)
        reg_ex = QRegExp(r"[A-Za-z0-9]{1,10}")  # <1>
        val_alphanum = QRegExpValidator(reg_ex, self.ui.le_alphanum)  # <2>
        self.ui.le_alphanum.setValidator(val_alphanum)  # <3>

        reg_ex = QRegExp(r"[a-z ]{0,30}")  # <1>
        val_lcspace = QRegExpValidator(reg_ex, self.ui.le_lcspace)  # <2>
        self.ui.le_lcspace.setValidator(val_lcspace)  # <3>

        val_nums_1_100 = QIntValidator(1, 100, self.ui.le_nums_1_100)  # <4>
        self.ui.le_nums_1_100.setValidator(val_nums_1_100)  # <5>

        val_float = QDoubleValidator(0.0, 20.0, 2, self.ui.le_float)  # <6>
        self.ui.le_float.setValidator(val_float)  # <7>
Exemplo n.º 9
0
    def __init__(self, slider):
        # slider: [ServoSlider]

        super().__init__()

        self.sliderWgt = slider
        self.minValue, self.maxValue = self.sliderWgt.getLimits()

        self.tmpMinValue = self.minValue
        self.tmpMaxValue = self.maxValue

        layout = wgt.QHBoxLayout(self)
        self.setLayout(layout)

        labelMax = wgt.QLabel('Max:', self)
        labelMin = wgt.QLabel('Min:', self)
        labelIdx = wgt.QLabel(
            'Servo {}'.format(str(self.sliderWgt.getIndex())), self)

        labelIdx.setFrameShape(wgt.QFrame.Panel)
        labelIdx.setFrameShadow(wgt.QFrame.Sunken)
        labelIdx.setLineWidth(1)

        self.textMax = wgt.QLineEdit(str(self.maxValue), self)
        self.textMax.setValidator(QIntValidator(0, 99999))
        self.textMax.editingFinished.connect(self.slotTextMaxChanged)

        self.textMin = wgt.QLineEdit(str(self.minValue), self)
        self.textMin.setValidator(QIntValidator(0, 99999))
        self.textMin.editingFinished.connect(self.slotTextMinChanged)

        layout.addWidget(labelIdx)
        layout.addWidget(labelMin)
        layout.addWidget(self.textMin)
        layout.addWidget(labelMax)
        layout.addWidget(self.textMax)
Exemplo n.º 10
0
    def __init__(self, parent=None):
        """
        Инициализация диалогового окна добавления высотной отметки к плану 
        """
        super(addHeightPointDialog, self).__init__(parent)
        self.parent = parent
        self.ui = uic.loadUi("./ui/HeightPlan-Add_height_point.ui", self)

        # Валидаторы полей формы
        HeightPail1PointValidator = QIntValidator(0, 100000, self)
        HeightPail2PointValidator = QIntValidator(0, 100000, self)
        WidthPlanePointValidator = QIntValidator(0, 300000, self)

        self.rail1Point = self.ui.HeightPail1Point
        self.rail2Point = self.ui.HeightPail2Point
        self.widthPlanePoint = self.ui.WidthPlanePoint
        self.planePoint = self.ui.PlanePoint

        self.rail1Point.setValidator(HeightPail1PointValidator)
        self.rail2Point.setValidator(HeightPail2PointValidator)
        self.widthPlanePoint.setValidator(WidthPlanePointValidator)

        self.updatePlanePointsOptions()
        self.clearFormFields()
Exemplo n.º 11
0
class QLineEditValidatorDemo(QWidget):
    def __init__(self):
        super(QLineEditValidatorDemo, self).__init__()
        self.int_line_edit = QLineEdit()
        self.double_line_edit = QLineEdit()
        self.validator_line_edit = QLineEdit()
        self.int_validator = QIntValidator()
        self.double_validator = QDoubleValidator()
        self.reg_validator = QRegExpValidator()
        self.form_layout = QFormLayout()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('校验器')

        self.form_layout.addRow('整数类型', self.int_line_edit)
        self.form_layout.addRow('浮点型', self.double_line_edit)
        self.form_layout.addRow('数字和字母', self.validator_line_edit)

        self.int_line_edit.setPlaceholderText('整型')
        self.double_line_edit.setPlaceholderText('浮点型')
        self.validator_line_edit.setPlaceholderText('数字和字母')

        self.int_validator.setRange(1, 99)
        self.double_validator.setRange(-360, 360)
        self.double_validator.setNotation(QDoubleValidator.StandardNotation)
        self.double_validator.setDecimals(2)

        _reg = QRegExp('[a-zA-Z0-9]+$')
        self.reg_validator.setRegExp(_reg)

        self.int_line_edit.setValidator(self.int_validator)
        self.double_line_edit.setValidator(self.double_validator)
        self.validator_line_edit.setValidator(self.reg_validator)

        self.setLayout(self.form_layout)
Exemplo n.º 12
0
    def change_correction_number(self):
        self.frame2 = QGroupBox(
            "Number of sessions before the corrections were applied")
        thresh_layout = QGridLayout()
        thresh_layout.addWidget(QLabel("Current number: "), 0, 0)
        self.correction_label = QLabel(str(self.correction))
        thresh_layout.addWidget(self.correction_label, 0, 1)
        thresh_layout.addWidget(QLabel("New value:"), 1, 0)

        self.correction_textbox = QLineEdit(self)
        only_number = QIntValidator()
        self.correction_textbox.setValidator(only_number)
        thresh_layout.addWidget(self.correction_textbox, 1, 1)

        self.frame2.setLayout(thresh_layout)
Exemplo n.º 13
0
    def add_flow_validators(self):

        # Validate source and destination IPv4 addresses
        ipv4Regex = QRegExp(
            "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
        )
        ipv4Validator = QRegExpValidator(ipv4Regex)
        self.ipDstLineEdit.setValidator(ipv4Validator)
        self.ipSrcLineEdit.setValidator(ipv4Validator)

        # Validate protocol number (0-255)
        self.protocolLineEdit.setValidator(QIntValidator(0, 255))
        self.protocolLineEdit.setMaxLength(3)

        # Validate port numbers (0-65535)
        self.portSrcLineEdit.setValidator(QIntValidator(0, 65535))
        self.portSrcLineEdit.setMaxLength(5)
        self.portDstLineEdit.setValidator(QIntValidator(0, 65535))
        self.portDstLineEdit.setMaxLength(5)

        valRegex = QRegExp("^([0-9])+$")
        valValidator = QRegExpValidator(valRegex)
        self.warn.setValidator(valValidator)
        self.al.setValidator(valValidator)
Exemplo n.º 14
0
    def initSetting(
        self
    ):  # setting 창 설정 함수(1) : lineEdit에서 type에 맞는 글자만 들어갈수 있도록 만든다.그리고 startButton click event을 해준다.
        self.onlyInt = QIntValidator()
        self.onlyDouble = QDoubleValidator()

        #restrict user input in QLineEdit
        self.z_min_lineEdit.setValidator(self.onlyInt)
        self.z_max_lineEdit.setValidator(self.onlyInt)
        self.interval_lineEdit.setValidator(self.onlyInt)
        self.sample_rate_lineEdit.setValidator(self.onlyDouble)
        self.p_value_lineEdit.setValidator(self.onlyDouble)

        # add button click event
        self.start_pushButton.clicked.connect(self.startGrah)
    def __init__(self, editors, record, parent=None):
        super(APISInputDialog, self).__init__(parent)
        self.editors = editors
        self.record = record
        layout = QFormLayout()
        for editor in self.editors:
            #QMessageBox.information(self, "info", "{}".format((editor["name"])))
            if editor["name"] != "ogc_fid":
                label = QLabel(editor["name"])
                #QMessageBox.information(None, "info", "{}".format(editor["type"]))
                if editor["type"] == QVariant.Int:
                    intVal = QIntValidator()
                    intVal.setBottom(0)
                    editor['lineEdit'].setValidator(intVal)
                layout.addRow(label, editor['lineEdit'])
                editor['lineEdit'].textEdited.connect(self.onTextEdited)

        self.uiSubmitBtn = QPushButton("Speichern")
        self.uiSubmitBtn.setEnabled(False)
        self.uiSubmitBtn.clicked.connect(self.saveInputAsQSqlRecord)
        layout.addRow(self.uiSubmitBtn)
        self.setLayout(layout)
        self.setWindowTitle("APIS Input Dialog")
        self.adjustSize()
Exemplo n.º 16
0
    def do_rdf_options(self):
        self.rdf_tool_options = QGroupBox('Options')
        lt = QHBoxLayout()

        self.rdf_ft_options = QGroupBox("Fourier Transform")
        layout = QFormLayout()
        self.rdf_ftsize = QLineEdit()
        self.rdf_ftsize.setValidator(QIntValidator())
        self.rdf_ftsize.setText(str(max(self.nprdf, 500)))
        layout.addRow(QLabel('FT bin size: '), self.rdf_ftsize)
        self.rdf_ft_options.setLayout(layout)

        self.toggle_rdf_ana_options(0)
        lt.addWidget(self.rdf_ft_options)
        self.rdf_tool_options.setLayout(lt)
Exemplo n.º 17
0
    def addInputField(self, _type):
        if self._inputField is None:
            self._inputFieldType = _type
            self._inputField = QLineEdit()
            if _type is float:
                self._inputField.setValidator(QDoubleValidator())
            elif _type is int:
                self._inputField.setValidator(QIntValidator())

            self._layout.addWidget(self._inputField)
            self._inputField.returnPressed.connect(
                self.onInputFieldReturnPressed)
        elif self._inputFieldType is not _type:
            raise ImproperlyConfigured("Input field for attribute '%s' configured twice with different types %s != %s"\
                    % (self._attribute, self._inputFieldType, _type))
Exemplo n.º 18
0
    def __init__(self, parent=None):
        """Initialize the class.

        Parameters
        ----------
        parent : None, optional
            Top-level widget.
        """
        super().__init__(parent)
        self.setupUi(self)
        self.name = 'Centroid'

        intValidator0 = QIntValidator(1, 10000)
        intValidator1 = QIntValidator(0, utils.LARGE_VALUE_FOR_VALIDATOR)
        intValidator2 = QIntValidator(1, utils.LARGE_VALUE_FOR_VALIDATOR)

        self.pixelAdditionXLineEdit.setValidator(intValidator0)
        self.minXLimitLineEdit.setValidator(intValidator1)
        self.maxXLimitLineEdit.setValidator(intValidator1)
        self.pixelAdditionYLineEdit.setValidator(intValidator0)
        self.minYLimitLineEdit.setValidator(intValidator1)
        self.maxYLimitLineEdit.setValidator(intValidator1)
        self.numHistoBinsLineEdit.setValidator(intValidator2)

        self.pixelAdditionXLineEdit.textChanged.connect(self.validateInput)
        self.minXLimitLineEdit.textChanged.connect(self.validateInput)
        self.maxXLimitLineEdit.textChanged.connect(self.validateInput)
        self.pixelAdditionYLineEdit.textChanged.connect(self.validateInput)
        self.minYLimitLineEdit.textChanged.connect(self.validateInput)
        self.maxYLimitLineEdit.textChanged.connect(self.validateInput)
        self.numHistoBinsLineEdit.textChanged.connect(self.validateInput)

        self.autoscaleXComboBox.currentIndexChanged.connect(
            self.handleAutoscaleChange)
        self.autoscaleYComboBox.currentIndexChanged.connect(
            self.handleAutoscaleChange)
Exemplo n.º 19
0
    def __init__(self):
        super().__init__()
        self.vbox = QVBoxLayout()
        self.box = QGroupBox()
        self.htop = QHBoxLayout()

        self.options = {k: QLineEdit('0') for k in self.names}
        for v in self.options.values():
            v.setValidator(QIntValidator(-100, 100))
        for k, v in self.options.items():
            self.htop.addWidget(QLabel(k))
            self.htop.addWidget(v)
        self.box.setLayout(self.htop)
        self.vbox.addWidget(self.box)
        self.setLayout(self.vbox)
Exemplo n.º 20
0
    def style_widgets(self):
        self.data_units_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.data_units_input.setMaximumWidth(100)

        self.smoothing_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

        self.window_length_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.window_length_input.setAlignment(Qt.AlignRight)
        self.window_length_input.setValidator(QIntValidator())
        self.window_length_input.setMaximumWidth(70)

        self.poly_order_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.poly_order_input.setAlignment(Qt.AlignRight)
        self.poly_order_input.setValidator(QIntValidator())
        self.poly_order_input.setMaximumWidth(70)

        self.rescale_AL_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

        self.fft_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

        self.fft_N_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.fft_N_input.setAlignment(Qt.AlignRight)
        self.fft_N_input.setRange(1, 20)
        self.fft_N_input.setMaximumWidth(70)
Exemplo n.º 21
0
    def getSettingsUI(self):
        settingsGroupBox = QGroupBox("Settings")
        settingsGridLayout = QGridLayout()
        self.upper_limit_checkbox = QCheckBox("Use upper limit", self)
        self.upper_limit_checkbox.stateChanged.connect(
            self.change_upper_limit_state)

        self.settings_upper_limit = QLineEdit()
        self.settings_upper_limit.setValidator(QIntValidator(0, 100000))
        self.settings_upper_limit.setMaximumWidth(50)

        settingsGridLayout.addWidget(self.upper_limit_checkbox, 0, 0)
        settingsGridLayout.addWidget(self.settings_upper_limit, 0, 1)
        settingsGroupBox.setLayout(settingsGridLayout)
        return settingsGroupBox
Exemplo n.º 22
0
    def style_widgets(self):

        self.disp_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.disp_label.setToolTip('Print basin-hopping status messages?')

        self.niter_basin_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.niter_basin_input.setAlignment(Qt.AlignRight)
        self.niter_basin_input.setValidator(QIntValidator())
        self.niter_basin_input.setMaximumWidth(70)

        self.temp_basin_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.temp_basin_input.setAlignment(Qt.AlignRight)
        self.temp_basin_input.setValidator(QDoubleValidator())
        self.temp_basin_input.setMaximumWidth(70)

        self.stepsize_basin_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.stepsize_basin_input.setAlignment(Qt.AlignRight)
        self.stepsize_basin_input.setValidator(QDoubleValidator())
        self.stepsize_basin_input.setMaximumWidth(70)

        self.interval_basin_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.interval_basin_input.setAlignment(Qt.AlignRight)
        self.interval_basin_input.setValidator(QIntValidator())
        self.interval_basin_input.setMaximumWidth(70)
Exemplo n.º 23
0
    def __init__(self, parent=None):
        QGroupBox.__init__(self, "ros master", parent)
        self.setCheckable(True)

        l = QHBoxLayout()
        self.setLayout(l)

        self.uriip = QLineEdit()
        self.uriport = QLineEdit()
        self.uriport.setValidator(QIntValidator())

        l.addWidget(QLabel("http://"))
        l.addWidget(self.uriip)
        l.addWidget(QLabel(":"))
        l.addWidget(self.uriport)
Exemplo n.º 24
0
    def btn_QLineEdit_Clicked(self):
        self.lineEdit.clear()  # 清空单行文本框内容
        self.lineEdit.setText("我爱你,我的祖国")
        self.print_Message(self.lineEdit.text())
        QApplication.processEvents()  # 刷新页面

        # P148页内容
        self.pIntLineEdit.setPlaceholderText("整型")  # 设置单行文本框提示信息
        pQIntValidator = QIntValidator(self)
        pQIntValidator.setRange(1, 99)  # 整型范围,1~99
        self.pIntLineEdit.setValidator(pQIntValidator)

        self.pDoubleLineEdit.setPlaceholderText("浮点型")
        pDoubleValidator = QDoubleValidator(self)
        pDoubleValidator.setRange(-360, 360)  # 浮点型范围-360~360
        pDoubleValidator.setNotation(QDoubleValidator.StandardNotation)
        pDoubleValidator.setDecimals(2)  # 小数点后2位
        self.pDoubleLineEdit.setValidator(pDoubleValidator)

        self.pValidatorLineEdit.setPlaceholderText("字母和数字")
        reg = QRegExp("[a-zA-Z0-9]+$")
        pValidator = QRegExpValidator(self)
        pValidator.setRegExp(reg)
        self.pValidatorLineEdit.setValidator(pValidator)
Exemplo n.º 25
0
    def initUI(self):
        self.setWindowTitle('编辑框校验器')

        # 生成一个表单布局
        formLayout = QFormLayout()

        # 生成三个编辑框
        intLineEdit = QLineEdit(self)
        doubleLineEdit = QLineEdit(self)
        validatorLineEdit = QLineEdit(self)

        formLayout.addRow('整数类型', intLineEdit)
        formLayout.addRow('浮点数类型', doubleLineEdit)
        formLayout.addRow('数字和字母', validatorLineEdit)

        intLineEdit.setPlaceholderText('整型')
        doubleLineEdit.setPlaceholderText('浮点型')
        validatorLineEdit.setPlaceholderText('数字和字母')

        self.setLayout(formLayout)

        # 生成校验器
        intvalidator = QIntValidator(self)
        intvalidator.setRange(0, 99)

        doublevalidator = QDoubleValidator(self)
        doublevalidator.setRange(-360, 360, 2)
        doublevalidator.setNotation(QDoubleValidator.StandardNotation)

        reg = QRegExp('[a-zA-Z0-9]+$')
        validator = QRegExpValidator(reg)

        # 添加校验器至编辑框
        intLineEdit.setValidator(intvalidator)
        doubleLineEdit.setValidator(doublevalidator)
        validatorLineEdit.setValidator(validator)
Exemplo n.º 26
0
    def __init__(self, application_database: DataStorage):
        # ------------------------ Internal Variables -------------------------
        self.app_data = application_database

        # ------------------------ Form Initialization ------------------------
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        # ----------------------- Widget Initialization -----------------------
        lhs_settings = self.app_data.reduced_doe_lhs_settings
        self.ui.lineEditNSamples.setText(str(lhs_settings['n_samples']))
        self.ui.lineEditNIter.setText(str(lhs_settings['n_iter']))
        self.ui.checkBoxIncVertices.setChecked(lhs_settings['inc_vertices'])

        # validators
        n_samples_validator = QIntValidator(3, 1e4, self.ui.lineEditNSamples)
        n_iter_validator = QIntValidator(2, 50, self.ui.lineEditNIter)

        self.ui.lineEditNSamples.setValidator(n_samples_validator)
        self.ui.lineEditNIter.setValidator(n_iter_validator)

        # --------------------------- Signals/Slots ---------------------------
        self.ui.buttonBox.accepted.connect(self.set_lhs_settings)
Exemplo n.º 27
0
 def __init__(self, parent, img_width, img_height):
     QDialog.__init__(self, parent)
     self.setupUi(self)
     self.frame.hide()
     self.resize(353, 200)
     validator = QIntValidator(self)
     self.widthEdit.setValidator(validator)
     self.heightEdit.setValidator(validator)
     self.spinWidth.setValue(img_width*2.54/300)
     self.spinHeight.setValue(img_height*2.54/300)
     self.checkBox.toggled.connect(self.toggleAdvanced)
     self.spinWidth.valueChanged.connect(self.onValueChange)
     self.spinHeight.valueChanged.connect(self.onValueChange)
     self.spinDPI.valueChanged.connect(self.onValueChange)
     self.widthEdit.setFocus()
Exemplo n.º 28
0
    def _SetInitValue(self):  # 초기값 설정
        #set Initial Value in each lineEdit
        self.lineEdit_AmbientTemp.setValidator(
            QIntValidator())  # Only Integer available.
        self.lineEdit_AmbientTemp.setText('70')
        self.lineEdit_PcbLayerNumber.setValidator(QIntValidator())
        self.lineEdit_PcbLayerNumber.setText('2')
        self.lineEdit_ComponentsNumber.setValidator(QIntValidator())
        self.lineEdit_ComponentsNumber.setText('1')

        self.tableWidget_PcbCaseInfor.setItem(
            0, 0, QTableWidgetItem("100"))  # PCB Width
        self.tableWidget_PcbCaseInfor.setItem(
            0, 1, QTableWidgetItem("100"))  # PCB Depth
        self.tableWidget_PcbCaseInfor.setItem(
            0, 2, QTableWidgetItem("1.6"))  # PCB Height
        self.tableWidget_PcbCaseInfor.setItem(
            1, 2, QTableWidgetItem("10"))  # Upper Height
        self.tableWidget_PcbCaseInfor.setItem(
            1, 3, QTableWidgetItem("5"))  # Upper Thickness
        self.tableWidget_PcbCaseInfor.setItem(
            2, 2, QTableWidgetItem("7"))  # Upper Height
        self.tableWidget_PcbCaseInfor.setItem(
            2, 3, QTableWidgetItem("5"))  # Upper Thickness
Exemplo n.º 29
0
    def __init__(self):
        # super(self, MyApp).__init__()
        super().__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        # set btn icon
        # https://icons8.com/icon/46514/eraser
        self.ui.erase_btn.setIcon(QIcon("icons/eraser.png"))
        # https: // www.iconfinder.com / icons / 48082 / delete_icon
        self.ui.x_btn.setIcon(QIcon("icons/delete.ico"))
        # Icon Farm-fresh made by FatCow Web Hosting from www.iconfinder.com
        # https://www.iconfinder.com/icons/36060/add_folder_icon
        self.ui.addfolder_btn.setIcon(QIcon("icons/add_folder.png"))
        # https://www.iconfinder.com/icons/36242/add_page_icon
        self.ui.addfile_btn.setIcon(QIcon("icons/add_file.png"))

        # set Some Var
        self.original_name_lst = []
        self.new_name_lst = []
        self.tmp_path = ""

        # set serial_LE, Order_LE, and delay_LE to eccept only Integer numbers
        onlyInt = QIntValidator()
        self.ui.serial_LE.setValidator(onlyInt)
        self.ui.order_LE.setValidator(onlyInt)
        self.ui.delay_LE.setValidator(onlyInt)

        # call method(s)
        self.btn_handler()
        self.add_item_to_cobox_mth("userinput.pset")
        self.add_item_to_cobox_mth("history.pset")

        # setup table widget and Column(s)
        self.ui.tableWidget.setColumnCount(4)
        self.ui.tableWidget.setHorizontalHeaderLabels(
            ["Original Name(s)", "Date", "Type", "Full Name"])
        self.ui.tableWidget.setColumnHidden(1, True)
        self.ui.tableWidget.setColumnHidden(2, True)
        self.ui.tableWidget.setColumnHidden(3, True)

        # set btn stats
        self.ui.addpreset_btn.setEnabled(False)
        self.ui.rename_btn.setEnabled(False)
        self.ui.unrename_btn.setEnabled(False)
        self.ui.clear_btn.setEnabled(False)
        self.ui.erase_btn.setEnabled(False)
        self.ui.x_btn.setEnabled(False)
Exemplo n.º 30
0
    def writeInput(self):

        self.write_input = QWidget()
        self.write_layout = QVBoxLayout(self.write_input)

        self.write_input_line = QWidget()
        self.write_input_layout = QHBoxLayout(self.write_input_line)

        self.array_config = QWidget()
        self.array_config_layout = QHBoxLayout(self.array_config)

        self.outpub_behaviour = QWidget()
        self.output_behaviour_layout = QHBoxLayout()

        self.write_txt = QLabel()
        self.write_txt.setText(QC.translate('', 'Do this with input:'))

        self.select_write_mode = QComboBox()
        self.select_write_mode.addItem(QC.translate('', 'Nothing'), QVariant('none'))
        self.select_write_mode.addItem(QC.translate('', 'Insert'), QVariant('i'))
        self.select_write_mode.addItem(QC.translate('', 'Append'), QVariant('a'))

        # maximum array size
        self.array_limits_cbox = QCheckBox()
        self.array_limits_cbox.stateChanged.connect(self.toggleArrayLimits)

        

        self.array_limit_txt = QLabel()
        self.array_limit_txt.setText(QC.translate('', 'Max. array elements:'))

        self.max_array_elements = QLineEdit()
        self.max_array_elements.setValidator(QIntValidator(1, 999))
        self.max_array_elements.setPlaceholderText(QC.translate('', 'Default value: 20'))


        self.array_config_layout.addWidget(self.array_limits_cbox)
        self.array_config_layout.addWidget(self.array_limit_txt)
        self.array_config_layout.addWidget(self.max_array_elements)



        self.write_input_layout.addWidget(self.write_txt)
        self.write_input_layout.addWidget(self.select_write_mode)
        #self.write_layout.addWidget(self.array_limits)

        self.write_layout.addWidget(self.write_input_line)
        self.write_layout.addWidget(self.array_config)
  def create_layout(self):
    layout = QVBoxLayout()

    groupbox = QGroupBox()
    groupbox_layout = QHBoxLayout()
    self.update_button = QRadioButton("Update")
    self.update_button.setChecked(True)
    self.update_button.toggled.connect(lambda: self.change_enabled_items("Update"))
    self.calculate_radio_button = QRadioButton("Calculate")
    self.calculate_radio_button.toggled.connect(lambda: self.change_enabled_items("Calculate"))

    groupbox_layout.addWidget(self.update_button)
    groupbox_layout.addWidget(self.calculate_radio_button)
    groupbox.setLayout(groupbox_layout)
    
    mid_layout = QHBoxLayout()

    update_layout = QVBoxLayout()
    update_line_label = QLabel("Update Calories Burnt")
    self.update_line_edit = QLineEdit()
    self.update_line_edit.setValidator(QIntValidator())
    update_layout.addWidget(update_line_label)
    update_layout.addWidget(self.update_line_edit)

    calculate_layout = QVBoxLayout()
    self.calculate_label = QLabel("Estimated Calories Burnt:")
    self.calculate_button = QPushButton("Calculate")
    self.calculate_button.clicked.connect(lambda: self.calculate_calories())
    self.calculate_button.setEnabled(False)
    calculate_layout.addWidget(self.calculate_label)
    calculate_layout.addWidget(self.calculate_button)

    mid_layout.addLayout(update_layout)
    mid_layout.addLayout(calculate_layout)
    
    buttons_layout = QHBoxLayout()
    save_button = QPushButton("Save")
    save_button.clicked.connect(lambda: self.save_calories())
    cancel_button = QPushButton("Cancel")
    cancel_button.clicked.connect(lambda: self.close())
    buttons_layout.addWidget(save_button)
    buttons_layout.addWidget(cancel_button)

    layout.addWidget(groupbox)
    layout.addLayout(mid_layout)
    layout.addLayout(buttons_layout)

    return layout
Exemplo n.º 32
0
    def rsiInput(self):

        self.rsi_input = QWidget()
        self.rsi_layout = QHBoxLayout(self.rsi_input)

        self.rsi_range_txt = QLabel()
        self.rsi_range_txt.setText(QC.translate('', 'Enter periods'))

        self.rsi_range_input = QLineEdit()
        self.rsi_range_input.setValidator(QIntValidator(1, 999))
        self.rsi_range_input.setPlaceholderText(QC.translate('', 'Default value: 3'))

        self.rsi_layout.addWidget(self.rsi_range_txt)
        self.rsi_layout.addWidget(self.rsi_range_input)

        self.variable_box.addWidget(self.rsi_input)
Exemplo n.º 33
0
    def __init__(self, *args, **kwargs):
        super().__init__("ROI histogram setup", *args, **kwargs)

        self._combo_cb = QComboBox()
        for v in self._available_combos:
            self._combo_cb.addItem(v)

        self._n_bins_le = SmartLineEdit("10")
        self._n_bins_le.setValidator(QIntValidator(1, 999))

        self._bin_range_le = SmartBoundaryLineEdit("-Inf, Inf")

        self.initUI()
        self.initConnections()

        self.setFixedHeight(self.minimumSizeHint().height())
Exemplo n.º 34
0
    def __init__(self, font, parent=None):
        super(GeneralTab, self).__init__(parent)
        mainLayout = QGridLayout(self)

        familyNameLabel = QLabel("Family name:", self)
        self.familyNameEdit = QLineEdit(font.info.familyName, self)
        styleNameLabel = QLabel("Style name:", self)
        self.styleNameEdit = QLineEdit(font.info.styleName, self)

        mainLayout.addWidget(familyNameLabel, 0, 0)
        mainLayout.addWidget(self.familyNameEdit, 0, 1, 1, 3)
        mainLayout.addWidget(styleNameLabel, 0, 4)
        mainLayout.addWidget(self.styleNameEdit, 0, 5)

        designerLabel = QLabel("Designer:", self)
        self.designerEdit = QLineEdit(font.info.openTypeNameDesigner, self)

        mainLayout.addWidget(designerLabel, 1, 0)
        mainLayout.addWidget(self.designerEdit, 1, 1, 1, 5)

        designerURLLabel = QLabel("Designer URL:", self)
        self.designerURLEdit = QLineEdit(
            font.info.openTypeNameDesignerURL, self)

        mainLayout.addWidget(designerURLLabel, 2, 0)
        mainLayout.addWidget(self.designerURLEdit, 2, 1, 1, 5)

        manufacturerLabel = QLabel("Manufacturer:", self)
        self.manufacturerEdit = QLineEdit(
            font.info.openTypeNameManufacturer, self)

        mainLayout.addWidget(manufacturerLabel, 3, 0)
        mainLayout.addWidget(self.manufacturerEdit, 3, 1, 1, 5)

        manufacturerURLLabel = QLabel("Manufacturer URL:", self)
        self.manufacturerURLEdit = QLineEdit(
            font.info.openTypeNameManufacturerURL, self)

        mainLayout.addWidget(manufacturerURLLabel, 4, 0)
        mainLayout.addWidget(self.manufacturerURLEdit, 4, 1, 1, 5)

        copyrightLabel = QLabel("Copyright:", self)
        self.copyrightEdit = QLineEdit(font.info.copyright, self)

        mainLayout.addWidget(copyrightLabel, 5, 0)
        mainLayout.addWidget(self.copyrightEdit, 5, 1, 1, 5)

        # TODO: give visual feedback of input data validity using QLineEdit
        # lose focus event
        # http://snorf.net/blog/2014/08/09/using-qvalidator-in-pyqt4-to-validate-user-input/ # noqa
        versionLabel = QLabel("Version:", self)
        if font.info.versionMajor is not None:
            versionMajor = str(font.info.versionMajor)
        else:
            versionMajor = ''
        self.versionMajorEdit = QLineEdit(versionMajor, self)
        self.versionMajorEdit.setAlignment(Qt.AlignRight)
        self.versionMajorEdit.setValidator(QIntValidator(self))
        versionDotLabel = QLabel(".", self)
        if font.info.versionMinor is not None:
            versionMinor = str(font.info.versionMinor)
        else:
            versionMinor = ''
        self.versionMinorEdit = QLineEdit(versionMinor, self)
        validator = QIntValidator(self)
        validator.setBottom(0)
        self.versionMinorEdit.setValidator(validator)

        mainLayout.addWidget(versionLabel, 6, 0)
        mainLayout.addWidget(self.versionMajorEdit, 6, 1)
        mainLayout.addWidget(versionDotLabel, 6, 2)
        mainLayout.addWidget(self.versionMinorEdit, 6, 3)

        dateCreatedLabel = QLabel("Date created:", self)
        dateTime = QDateTime()
        # dateTime.fromString(font.info.openTypeHeadCreated, "yyyy/MM/dd
        # hh:mm:ss") # XXX: why does this not work?
        dateCreated = font.info.openTypeHeadCreated
        if dateCreated:
            parse = dateCreated.split(" ")
            if len(parse) == 2:
                date = parse[0].split("/")
                date = QDate(*(int(val) for val in date))
                dateTime.setDate(date)
                time = parse[1].split(":")
                time = QTime(*(int(val) for val in time))
                dateTime.setTime(time)
        else:
            cur = QDateTime.currentDateTime()
            dateTime.setDate(cur.date())
            dateTime.setTime(cur.time())
        self.dateCreatedEdit = QDateTimeEdit(dateTime, self)

        mainLayout.addWidget(dateCreatedLabel, 6, 4)
        mainLayout.addWidget(self.dateCreatedEdit, 6, 5)

        licenseLabel = QLabel("License:", self)
        self.licenseEdit = QLineEdit(font.info.openTypeNameLicense, self)

        mainLayout.addWidget(licenseLabel, 7, 0)
        mainLayout.addWidget(self.licenseEdit, 7, 1, 1, 5)

        licenseURLLabel = QLabel("License URL:", self)
        self.licenseURLEdit = QLineEdit(font.info.openTypeNameLicenseURL, self)

        mainLayout.addWidget(licenseURLLabel, 8, 0)
        mainLayout.addWidget(self.licenseURLEdit, 8, 1, 1, 5)

        trademarkLabel = QLabel("Trademark:", self)
        self.trademarkEdit = QLineEdit(font.info.trademark, self)

        mainLayout.addWidget(trademarkLabel, 9, 0)
        mainLayout.addWidget(self.trademarkEdit, 9, 1, 1, 5)

        self.setLayout(mainLayout)
Exemplo n.º 35
0
    def __init__(self, font, parent=None):
        super(MetricsTab, self).__init__(parent)
        mainLayout = QGridLayout()

        styleMapFamilyLabel = QLabel("Style map family name:", self)
        self.styleMapFamilyEdit = QLineEdit(font.info.styleMapFamilyName, self)

        styleMapStyleLabel = QLabel("Style map style name:", self)
        self.styleMapStyleDrop = QComboBox(self)
        items = ["None", "Regular", "Italic", "Bold", "Bold Italic"]
        self.styleMapStyleDrop.insertItems(0, items)
        sn = font.info.styleMapStyleName
        if sn == "regular":
            self.styleMapStyleDrop.setCurrentIndex(1)
        elif sn == "regular italic":
            self.styleMapStyleDrop.setCurrentIndex(2)
        elif sn == "bold":
            self.styleMapStyleDrop.setCurrentIndex(3)
        elif sn == "bold italic":
            self.styleMapStyleDrop.setCurrentIndex(4)
        else:
            self.styleMapStyleDrop.setCurrentIndex(0)

        mainLayout.addWidget(styleMapFamilyLabel, 0, 0)
        mainLayout.addWidget(self.styleMapFamilyEdit, 0, 1, 1, 3)
        mainLayout.addWidget(styleMapStyleLabel, 0, 4)
        mainLayout.addWidget(self.styleMapStyleDrop, 0, 5)

        unitsPerEmLabel = QLabel("Units per em:", self)
        unitsPerEm = str(
            font.info.unitsPerEm) if font.info.unitsPerEm is not None else ''
        self.unitsPerEmEdit = QLineEdit(unitsPerEm, self)
        validator = QIntValidator(self)
        validator.setBottom(0)
        self.unitsPerEmEdit.setValidator(validator)

        ascenderLabel = QLabel("Ascender:", self)
        ascender = str(
            font.info.ascender) if font.info.ascender is not None else ''
        self.ascenderEdit = QLineEdit(ascender, self)
        self.ascenderEdit.setValidator(QIntValidator(self))

        capHeightLabel = QLabel("Cap height:", self)
        capHeight = str(
            font.info.capHeight) if font.info.capHeight is not None else ''
        self.capHeightEdit = QLineEdit(capHeight, self)
        self.capHeightEdit.setValidator(QIntValidator(self))

        mainLayout.addWidget(unitsPerEmLabel, 1, 0)
        mainLayout.addWidget(self.unitsPerEmEdit, 1, 1)
        mainLayout.addWidget(ascenderLabel, 1, 2)
        mainLayout.addWidget(self.ascenderEdit, 1, 3)
        mainLayout.addWidget(capHeightLabel, 1, 4)
        mainLayout.addWidget(self.capHeightEdit, 1, 5)

        italicAngleLabel = QLabel("Italic angle:", self)
        italicAngle = str(
            font.info.italicAngle) if font.info.italicAngle is not None else ''
        self.italicAngleEdit = QLineEdit(italicAngle, self)
        self.italicAngleEdit.setValidator(QDoubleValidator(self))

        descenderLabel = QLabel("Descender:", self)
        descender = str(
            font.info.descender) if font.info.descender is not None else ''
        self.descenderEdit = QLineEdit(descender, self)
        self.descenderEdit.setValidator(QIntValidator(self))

        xHeightLabel = QLabel("x-height:", self)
        xHeight = str(
            font.info.xHeight) if font.info.xHeight is not None else ''
        self.xHeightEdit = QLineEdit(xHeight, self)
        self.xHeightEdit.setValidator(QIntValidator(self))

        mainLayout.addWidget(italicAngleLabel, 2, 0)
        mainLayout.addWidget(self.italicAngleEdit, 2, 1)
        mainLayout.addWidget(descenderLabel, 2, 2)
        mainLayout.addWidget(self.descenderEdit, 2, 3)
        mainLayout.addWidget(xHeightLabel, 2, 4)
        mainLayout.addWidget(self.xHeightEdit, 2, 5)

        noteLabel = QLabel("Note:", self)
        self.noteEdit = QPlainTextEdit(font.info.note, self)

        mainLayout.addWidget(noteLabel, 3, 0)
        mainLayout.addWidget(self.noteEdit, 3, 1, 1, 5)

        self.setLayout(mainLayout)
Exemplo n.º 36
0
    def setUp(self):
        self.setWindowTitle("Settings")
        self.setSizeGripEnabled(False)

        self.layout = QGridLayout(self)
        self.layout.setSizeConstraint(QLayout.SetFixedSize)

        # ---------------------------------------------------------------------
        portValidator = QIntValidator(self)
        portValidator.setTop(65536)
        portValidator.setBottom(0)

        self.portStartEdit = QLineEdit(str(self.config['port_start']), self)
        self.portStartEdit.setValidator(portValidator)
        self.portEndEdit = QLineEdit(str(self.config['port_end']), self)
        self.portEndEdit.setValidator(portValidator)

        portsLayout = QHBoxLayout()
        portsLayout.addWidget(self.portStartEdit)
        portsLayout.addWidget(self.portEndEdit)
        self.layout.addWidget(QLabel("Listen port range:", self), 0, 0)
        self.layout.addLayout(portsLayout, 0, 1)
        # ---------------------------------------------------------------------
        speedValidator = QIntValidator(self)
        speedValidator.setBottom(0)

        maxDownloadSpeed = str(round(self.config['max_download_speed'] / 1024))
        maxUploadSpeed = str(round(self.config['max_upload_speed'] / 1024))
        self.maxDownSpeedEdit = QLineEdit(maxDownloadSpeed, self)
        self.maxDownSpeedEdit.setValidator(speedValidator)
        self.maxUpSpeedEdit = QLineEdit(maxUploadSpeed, self)
        self.maxUpSpeedEdit.setValidator(speedValidator)

        self.layout.addWidget(QLabel("Maximum download speed (KB/s):", self),
                              1, 0)
        self.layout.addWidget(self.maxDownSpeedEdit, 1, 1)
        self.layout.addWidget(QLabel("Maximum upload speed (KB/s):", self),
                              2, 0)
        self.layout.addWidget(self.maxUpSpeedEdit, 2, 1)
        # ---------------------------------------------------------------------
        torrentCountValidator = QIntValidator(self)
        torrentCountValidator.setTop(50)
        torrentCountValidator.setBottom(2)

        self.torrentCountEdit = QLineEdit(str(self.config['max_torrents']),
                                          self)
        self.torrentCountEdit.setValidator(torrentCountValidator)

        self.layout.addWidget(QLabel("Maximal torrent count:", self), 3, 0)
        self.layout.addWidget(self.torrentCountEdit, 3, 1)
        # ---------------------------------------------------------------------
        activeTorrentsValidator = QIntValidator(self)
        activeTorrentsValidator.setBottom(0)

        self.maxActiveDownloadsEdit = QLineEdit(
                str(self.config['max_active_downloads']), self)
        self.maxActiveDownloadsEdit.setValidator(activeTorrentsValidator)
        self.maxActiveSeedsEdit = QLineEdit(
                str(self.config['max_active_seeds']), self)
        self.maxActiveSeedsEdit.setValidator(activeTorrentsValidator)

        self.layout.addWidget(QLabel("Maximum active downloads:", self), 4, 0)
        self.layout.addWidget(self.maxActiveDownloadsEdit, 4, 1)
        self.layout.addWidget(QLabel("Maximum active seeds:", self), 5, 0)
        self.layout.addWidget(self.maxActiveSeedsEdit, 5, 1)
        # ---------------------------------------------------------------------
        self.resumeDataCheckbox = QCheckBox(self)
        self.resumeDataCheckbox.setChecked(self.config['resume_data'] == 1)

        self.layout.addWidget(QLabel("Enable resume data:", self), 6, 0)
        self.layout.addWidget(self.resumeDataCheckbox, 6, 1)
        # ---------------------------------------------------------------------
        buttonsRow = QHBoxLayout()

        OKButton = QPushButton("Apply", self)
        OKButton.setFocus()
        OKButton.clicked.connect(self.accept)

        cancelButton = QPushButton("Cancel", self)
        cancelButton.clicked.connect(self.reject)

        buttonsRow.addWidget(OKButton)
        buttonsRow.addWidget(cancelButton)
        self.layout.addLayout(buttonsRow, 7, 1)