Пример #1
0
    def __init__(self, parent=None):
        super(SegmentTab, self).__init__(parent)

        self.grid = QGridLayout(self)

        self.segmentBtn = QPushButton('Toggle segment', self)
        self.segmentBtn.setCheckable(True)
        self.grid.addWidget(self.segmentBtn, 0, 0)

        scaleLabel = QLabel('Scale:', self)
        scaleLabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.grid.addWidget(scaleLabel, 1, 0, Qt.AlignRight)

        self.scaleInput = QLineEdit(self)
        # TODO set this from SegmentManager's default
        self.scaleInput.setPlaceholderText('2.0')
        validator = QDoubleValidator()
        validator.setNotation(QDoubleValidator.StandardNotation)
        self.scaleInput.setValidator(validator)
        self.grid.addWidget(self.scaleInput, 1, 1)

        self.scaleCombo = QComboBox(self)
        for size, _ in self.SCALE_SIZES:
            self.scaleCombo.addItem(size)
        self.grid.addWidget(self.scaleCombo, 1, 2)

        spacer = QSpacerItem(40, 20, QSizePolicy.Minimum,
                             QSizePolicy.Expanding)
        self.grid.addItem(spacer, 2, 0)

        self.segmentBtn.clicked.connect(self.onSegmentBtnClicked)
        self.scaleInput.textChanged.connect(self.onScaleInputChanged)
        self.scaleCombo.activated.connect(self.setScalePreset)
Пример #2
0
    def initUI(self):
        self.setWindowTitle("校验器")
        #创建表单布局
        formlayout = QFormLayout()
        intLineEdit = QLineEdit()
        doubleLineEdit = QLineEdit()
        validatorLineEdit = QLineEdit()

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

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

        # 整数校验器
        intValidator = QIntValidator(self)
        intValidator.setRange(1, 99)
        #浮点校验器
        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-360, 360)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        #设置精度,小数点2位
        doubleValidator.setDecimals(2)
        #字符和数字
        reg = QRegExp('[a-zA-Z0-9]+$')
        validator = QRegExpValidator(self)
        validator.setRegExp(reg)
        #设置校验器
        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(doubleValidator)
        validatorLineEdit.setValidator(validator)
        self.setLayout(formlayout)
Пример #3
0
    def setUI(self):
        self.setWindowTitle('校验器')

        formLayout = QFormLayout()
        intLineEdit = QLineEdit()
        doubleLineEdit = QLineEdit()
        validatorLineEdit = QLineEdit()

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

        intLineEdit.setPlaceholderText('整形')
        doubleLineEdit.setPlaceholderText('浮点型')
        validatorLineEdit.setPlaceholderText('字母和数字')
        #整数校验器
        intValidator = QIntValidator(self)
        intValidator.setRange(1, 99)
        #浮点数校验器
        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-360, 360)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        #设置精度
        doubleValidator.setDecimals(2)
        #字母和数字
        reg = QRegExp('[a-zA-z0-9]+$')
        validator = QRegExpValidator(self)
        validator.setRegExp(reg)
        #设置校验器
        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(doubleValidator)
        validatorLineEdit.setValidator(validator)

        self.setLayout(formLayout)
Пример #4
0
    def initUI(self):
        self.setWindowTitle("校验器")
        formlayout = QFormLayout()
        INT = QLineEdit()
        DOUBLE = QLineEdit()
        REG = QLineEdit()

        formlayout.addRow("整数类型", INT)
        formlayout.addRow("浮点数", DOUBLE)
        formlayout.addRow("数字和字母", REG)

        INT.setPlaceholderText("整型")
        DOUBLE.setPlaceholderText("浮点型")
        REG.setPlaceholderText("字母和数字")

        intvalidator = QIntValidator(self)
        intvalidator.setRange(1, 99)

        doublevalidator = QDoubleValidator(self)
        doublevalidator.setRange(-360, 360)
        doublevalidator.setNotation(QDoubleValidator.StandardNotation)  #标准显示法
        doublevalidator.setDecimals(2)  #设置精度

        reg = QRegExp('[a-zA-Z0-9]+$')
        RegExpValidator = QRegExpValidator(self)
        RegExpValidator.setRegExp(reg)

        #设置校验器
        INT.setValidator(intvalidator)
        DOUBLE.setValidator(doublevalidator)
        REG.setValidator(RegExpValidator)

        self.setLayout(formlayout)
    def initUI(self):
        self.setWindowTitle('QlineLabel校验器')
        formlayout = QFormLayout(self)
        intLineEdit = QLineEdit()
        doubleLineEidt = QLineEdit()
        validatorLineEdit = QLineEdit()

        formlayout.addRow('整数类型', intLineEdit)
        formlayout.addRow('浮点数 ', doubleLineEidt)
        formlayout.addRow('数字字母', validatorLineEdit)

        intLineEdit.setPlaceholderText('整数')
        doubleLineEidt.setPlaceholderText('浮点数')
        validatorLineEdit.setPlaceholderText('字母')

        # 整数校验器
        intValidator = QIntValidator(self)
        intValidator.setRange(1, 99)
        doubleValidator = QDoubleValidator(self)

        doubleValidator.setRange(-360, 360)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        doubleValidator.setDecimals(2)
        reg = QRegExp('[a-zA-Z0-9]+$')
        validator = QRegExpValidator(self)
        validator.setRegExp(reg)

        intLineEdit.setValidator(intValidator)
        doubleLineEidt.setValidator(doubleValidator)
        validatorLineEdit.setValidator(validator)
Пример #6
0
    def initUI(self):
        locale.setlocale(locale.LC_ALL, '')
        self.numberEdit = QLineEdit()
        # theValidator = QIntValidator(0, 1999999999)   # 최대 숫자 제한
        # 최소수(0),최대수(99억),소수점 뒤 갯수(0)
        theValidator = QDoubleValidator(0, 9999999999, 0)
        theValidator.setNotation(QDoubleValidator.StandardNotation)
        self.numberEdit.setValidator(theValidator)
        self.numberEdit.setMaxLength(10)
        # theLocale = QLocale()
        # theLocale.toString
        # # theLocale.setNumberOptions(QLocale.DefaultNumberOptions)
        # # theLocale.currencySymbol(QLocale.CurrencyIsoCode)
        # theLocale.setNumberOptions(QLocale.OmitGroupSeparator)
        # self.numberEdit.setLocale(theLocale)
        # self.numberEdit.setInputMask('#,###,###,###')
        # self.numberEdit.setInputMask('0,000,000,000')
        # self.numberEdit.setInputMask('+99_9999_999999')     # 국제 전화번호
        self.numberEdit.textChanged.connect(self.__textChanged)
        self.numberEdit.returnPressed.connect(self.__textReturned)

        vbox = QVBoxLayout()
        vbox.addWidget(self.numberEdit)
        vbox.addStretch()

        self.setLayout(vbox)

        self.setWindowTitle('TEST')
        self.setGeometry(300, 300, 300, 200)
Пример #7
0
    def initUI(self):
        self.setWindowTitle('校验器')

        formLayout = QFormLayout()
        intLineEdit = QLineEdit()
        doubleLineEdit = QLineEdit()
        regLineEdit = QLineEdit()

        formLayout.addRow('整数', intLineEdit)
        formLayout.addRow('浮点数', doubleLineEdit)
        formLayout.addRow('正则表达式', regLineEdit)

        intLineEdit.setPlaceholderText('整型数字')
        doubleLineEdit.setPlaceholderText('浮点数')
        regLineEdit.setPlaceholderText('正则表达式')

        intValidator = QIntValidator()
        intValidator.setRange(0, 1000)

        doubleValidator = QDoubleValidator()
        doubleValidator.setRange(-100, 100)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        doubleValidator.setDecimals(2)  # 小数精度

        reg = QRegExp(r"[a-zA-Z0-9]+$")
        regValidator = QRegExpValidator(self)
        regValidator.setRegExp(reg)

        # 设置校验器
        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(doubleValidator)
        regLineEdit.setValidator(regValidator)

        self.setLayout(formLayout)
    def set_validator(self):

        doubleValitor = QDoubleValidator()
        doubleValitor.setBottom(0)
        doubleValitor.setDecimals(2)
        doubleValitor.setNotation(QDoubleValidator.StandardNotation)
        self.planamount.setValidator(doubleValitor)
Пример #9
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('字母、数字和下划线')

        pIntValidator = QIntValidator(self)
        pIntValidator.setRange(0, 99)

        pDoubleValidator = QDoubleValidator(self)
        pDoubleValidator.setRange(-360, 360)
        pDoubleValidator.setNotation(
            QDoubleValidator.StandardNotation)  # 分标准浮点记数和科学浮点记数
        pDoubleValidator.setDecimals(2)

        r = QRegExp(r'^[a-zA-Z0-9\_]+$')
        pReValidator = QRegExpValidator(self)
        pReValidator.setRegExp(r)

        pIntlineEdit.setValidator(pIntValidator)
        pDoublelineEdit.setValidator(pDoubleValidator)
        pValidatorlineEdit.setValidator(pReValidator)

        self.setLayout(flo)
Пример #10
0
    def initUI(self):
        self.setWindowTitle('校验器')

        formLayout = QFormLayout()
        IntLineEdit = QLineEdit()
        DoubleLineEdit = QLineEdit()
        validatorLineEdit = QLineEdit()

        formLayout.addRow('int', IntLineEdit)
        formLayout.addRow('double', DoubleLineEdit)
        formLayout.addRow('数字和字母', validatorLineEdit)

        IntLineEdit.setPlaceholderText('整型')

        #整数校验器1-99
        intValidator = QIntValidator(self)
        intValidator.setRange(1, 99)
        #浮点
        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-360, 360)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        doubleValidator.setDecimals(2)  #小数点2位

        #字符和数字
        reg = QRegExp('[a-zA-Z0-9]+$')
        validator = QRegExpValidator(self)
        validator.setRegExp(reg)

        #设置校验器
        IntLineEdit.setValidator(intValidator)
        DoubleLineEdit.setValidator(doubleValidator)
        validatorLineEdit.setValidator(validator)

        self.setLayout(formLayout)
    def initUI(self):

        self.setWindowTitle("校验器")

        formlayout = QFormLayout(self)

        intLineEdit = QLineEdit()
        doubleLineEdit = QLineEdit()
        validatorLineEdit = QLineEdit()

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

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

        intValidator = QIntValidator(self)
        intValidator.setRange(1, 99)

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

        reg = QRegExp('[a-zA-z0-9]+$')
        validator = QRegExpValidator(self)
        validator.setRegExp(reg)

        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(floatValidator)
        validatorLineEdit.setValidator(validator)
Пример #12
0
    def initUI(self):
        self.setWindowTitle('校验器')

        intLineEdit = QLineEdit()
        doubleLineEdit = QLineEdit()
        regExpLineEdit = QLineEdit()

        intLineEdit.setPlaceholderText('整数')
        doubleLineEdit.setPlaceholderText('小数')
        regExpLineEdit.setPlaceholderText('字母和数字')

        # 创建校验器
        intValidator = QIntValidator(self)
        intValidator.setRange(1, 50)  # [1,50]取值范围
        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-100, 100, 2)  # [-100,100]小数点后两位
        doubleValidator.setNotation(
            QDoubleValidator.StandardNotation)  # 标准化将字符串转为double
        regExpValidator = QRegExpValidator(self)
        reg = QRegExp('[a-zA-Z0-9]+$')
        regExpValidator.setRegExp(reg)

        # 设置校验器
        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(doubleValidator)
        regExpLineEdit.setValidator(regExpValidator)

        formLayout = QFormLayout()
        formLayout.addRow('整型类型', intLineEdit)
        formLayout.addRow('浮点类型', doubleLineEdit)
        formLayout.addRow('数字和字母', regExpLineEdit)
        self.setLayout(formLayout)
Пример #13
0
    def __init__(self, Property, parent=None, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        #self.components = []
        self.prop = Property
        #self.prop.

        layout = QHBoxLayout(self)
        #for i in range(num_components):
        self.c = QLineEdit(str(self.prop.Value), self)
        #c.textChanged.connect(self.doEdit)
        self.ed_izm = QLabel(self.prop.Ed_izm)
        validator = QDoubleValidator(0.99, 99.99, 2)
        validator.setNotation(QDoubleValidator.StandardNotation)
        self.c.setValidator(validator)
        self.c.setAlignment(Qt.AlignRight)
        self.c.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Expanding)
        #self.components.append(c)
        self.c.setMaximumWidth(100)
        layout.addWidget(self.c, stretch=1)
        layout.addWidget(self.ed_izm)
        """
        for i in range(num_components, max_columns):
            lbl = QLabel('')
            lbl.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Expanding)
            layout.addWidget(lbl, stretch=1)
        """
        layout.setContentsMargins(0, 0, 20, 0)
        self.c.editingFinished.connect(self._doEdit)
        self.setLayout(layout)
Пример #14
0
    def init_ui(self):
        self.setWindowTitle('教验器')

        #创建表单布局
        formLayout = QFormLayout(self)

        intLineEdit = QLineEdit()
        doubleLineEdit = QLineEdit()
        validatorLineEdit = QLineEdit()

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

        #int validator
        intValidator = QIntValidator(self)
        intValidator.setRange(1, 99)

        #double validator
        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-360, 360)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        doubleValidator.setDecimals(2)

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

        #设置jiaoyanqi
        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(doubleValidator)
        validatorLineEdit.setValidator(validator)
        self.setLayout(formLayout)
Пример #15
0
 def addStatControl(self,i,label=None):
     statbox = QHBoxLayout()
     statbox.addSpacing(1)
     statbox.setSpacing(0)
     statbox.setAlignment(Qt.AlignCenter)
     statlabel = QLabel(self.stats[i] if label is None else label)
     statlabel.setContentsMargins(0,0,0,0)
     statlabel.setAlignment(Qt.AlignCenter)
     statlabel.setFixedWidth(20)
     statbox.addWidget(statlabel)
     statcontrol = QLineEdit()
     statcontrol.setAlignment(Qt.AlignCenter)
     statcontrol.setFixedWidth(40)
     statcontrol.setText(str(self.skill.multipliers[i]))
     v = QDoubleValidator(0,99,3,statcontrol)
     v.setNotation(QDoubleValidator.StandardNotation)
     #v.setRange(0,100,decimals=3)
     statcontrol.setValidator(v)
     #print(v.top())
     def statFuncMaker(j):
         def statFunc(newValue):
             self.skill.multipliers[j] = float(newValue)
             self.skillsChanged.emit()
         return statFunc
     statcontrol.textChanged[str].connect(statFuncMaker(i))
     statbox.addWidget(statcontrol)
     statbox.addSpacing(1)
     self.layout.addLayout(statbox)
Пример #16
0
    def initUI(self):
        lineedit1 = QLineEdit()
        lineedit2 = QLineEdit()
        lineedit3 = QLineEdit()

        # 整数验证
        intValidator = QIntValidator(self)
        # 如何1到111?
        intValidator.setRange(1, 99)

        # 正则验证
        regvalidator = QRegExpValidator(self)
        reg = QRegExp("^[A-Z][0-9]{2}$")
        regvalidator.setRegExp(reg)

        # 浮点型验证
        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-99, 99)
        # 作用是什么
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        doubleValidator.setDecimals(2)

        lineedit1.setValidator(intValidator)
        lineedit2.setValidator(regvalidator)
        lineedit3.setValidator(doubleValidator)

        lineedit2.setPlaceholderText('字母数字数字')

        formlayout = QFormLayout()
        formlayout.addRow('数字', lineedit1)
        formlayout.addRow('正则', lineedit2)
        formlayout.addRow('两位小数', lineedit3)

        self.setLayout(formlayout)
Пример #17
0
 def __init__(self):
     super().__init__()
     self.setAlignment(Qt.AlignCenter)
     self.setSizePolicy(QSizePolicy())
     v = QDoubleValidator(0,99,3,self)
     v.setNotation(QDoubleValidator.StandardNotation)
     self.setValidator(v)
     self.textChanged[str].connect(self.updateGeometry)
     self.setFrame(False)
     self.setAttribute(Qt.WA_MacShowFocusRect, 0);
     self.editingFinished.connect(self.clearFocus)
     self.setContextMenuPolicy(Qt.NoContextMenu)
     self.setReadOnly(True)
     self.setStyleSheet('''
         QLineEdit {
             border-width: 1px;
             border-style: solid;
             border-radius: 7px;
             border-color: gray;
             padding: 0px 1px 0px 1px;
             background: transparent;
         }
         QLineEdit::focus {
             background: gray;
         }
     ''')
Пример #18
0
    def init(self):
        # 开始按键
        self.pushButton.clicked.connect(self.pushButton_event)
        # 结束按键
        self.pushButton_2.clicked.connect(self.pushButton_event2)

        # 限制为数字和字符
        self.lineEdit.setPlaceholderText("只能键入数字和字符") 
        reg = QRegExp("[a-zA-Z0-9]+$")
        LE1Validator = QRegExpValidator(self)
        LE1Validator.setRegExp(reg)
        self.lineEdit.setValidator(LE1Validator)
        #设置浮点数限制 范围0~86400,小数点1位
        LE2Validator = QDoubleValidator(self)
        LE2Validator.setRange(0, 86400)
        LE2Validator.setNotation(QDoubleValidator.StandardNotation)
        LE2Validator.setDecimals(1)
        self.lineEdit_2.setValidator(LE2Validator)
        self.lineEdit_2.setPlaceholderText("最小为0.1s")

        self.lineEdit_3.setValidator(LE2Validator)
        self.lineEdit_3.setPlaceholderText("最小为0.1s")


        # 启动后台
        self.lk.start()
Пример #19
0
    def init(self):
        # create a formLayout
        form_layout = QFormLayout(self)

        int_line_edit = QLineEdit()
        double_line_edit = QLineEdit()
        reg_line_edit = QLineEdit()

        form_layout.addRow("int", int_line_edit)
        form_layout.addRow("double", double_line_edit)
        form_layout.addRow("regular", reg_line_edit)

        int_line_edit.setPlaceholderText("int")
        double_line_edit.setPlaceholderText("double")
        reg_line_edit.setPlaceholderText("regular")

        int_validator = QIntValidator()
        int_validator.setRange(1, 99)

        double_validator = QDoubleValidator()
        double_validator.setRange(-100, 100)
        double_validator.setNotation(QDoubleValidator.StandardNotation)
        double_validator.setDecimals(2)

        reg_validator = QRegExpValidator()
        reg_validator.setRegExp(QRegExp('[0-9a-zA-Z]'))

        # set validator
        int_line_edit.setValidator(int_validator)
        double_line_edit.setValidator(double_validator)
        reg_line_edit.setValidator(reg_validator)

        self.setLayout(form_layout)
Пример #20
0
class LineEdit(QLineEdit):
    checkVal = pyqtSignal(float)

    def __init__(self, *args, **kwargs):
        super(LineEdit, self).__init__(*args, **kwargs)
        self.validator = QDoubleValidator()
        self.setValidator(self.validator)
        self.textChanged.connect(self.new_text)
        self.returnPressed.connect(self.check_validator)
        self.ntext = self.text()

    def new_text(self, text):
        if self.hasAcceptableInput():
            self.ntext = text

    def keyPressEvent(self, event):
        super().keyPressEvent(event)
        if event.key() == Qt.Key_Return and not self.hasAcceptableInput():
            self.check_validator()

    def check_validator(self):
        try:
            if float(self.text()) > self.validator.top():
                self.setText(str(self.validator.top()))
            elif float(self.text()) < self.validator.bottom():
                self.setText(str(self.validator.bottom()))
        except ValueError:
            QMessageBox.about(self, "Error", "Input can only be a number")
            self.setText(self.ntext)
        self.checkVal.emit(float(self.ntext))

    def valRange(self, x1, x2):
        self.validator.setRange(x1, x2)
        self.validator.setDecimals(6)
        self.validator.setNotation(QDoubleValidator.StandardNotation)
Пример #21
0
    def __init__(self):
        super().__init__()

        intValidator = QLineEdit()
        doubleValidator = QLineEdit()
        inputMask = QLineEdit()
        text = QLineEdit()
        password = QLineEdit()
        readOnly = QLineEdit("Hello PyQt5")

        intValidator.setValidator(QIntValidator())
        intValidator.setMaxLength(4)
        intValidator.setAlignment(Qt.AlignRight)
        intValidator.setFont(QFont("Arial", 20))

        _double = QDoubleValidator(0.99, 99.99, 2)
        _double.setNotation(QDoubleValidator.StandardNotation)
        doubleValidator.setValidator(_double)
        inputMask.setInputMask('+99_9999_999999')
        text.textChanged.connect(self.textChanged)
        password.setEchoMode(QLineEdit.Password)
        readOnly.setReadOnly(True)

        formLayout = QFormLayout()
        formLayout.addRow("Integer Validator", intValidator)
        formLayout.addRow("Double Validator", doubleValidator)
        formLayout.addRow("Input Mask", inputMask)
        formLayout.addRow("Text Changed", text)
        formLayout.addRow("Password", password)
        formLayout.addRow("ReadOnly", readOnly)

        self.setLayout(formLayout)
Пример #22
0
    def initUI(self):
        self.add_sensor_confirm.clicked.connect(self.insert_sensor_into_db)
        self.add_sensor_cancle.clicked.connect(self.close)
        self.voltage1_input.textChanged.connect(self.updateUI)
        self.voltage2_input.textChanged.connect(self.updateUI)
        self.pressure1_input.textChanged.connect(self.updateUI)
        self.pressure2_input.textChanged.connect(self.updateUI)
        self.value2_input.textChanged.connect(self.updateUI)
        self.value1_input.textChanged.connect(self.updateUI)

        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-10000, 10000)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        doubleValidator.setDecimals(4)
        self.value1_input.setValidator(doubleValidator)
        self.value2_input.setValidator(doubleValidator)
        self.pressure2_input.setValidator(doubleValidator)
        self.pressure1_input.setValidator(doubleValidator)
        self.voltage2_input.setValidator(doubleValidator)
        self.voltage1_input.setValidator(doubleValidator)
        self.vp_input.setValidator(doubleValidator)
        self.zv_input.setValidator(doubleValidator)
        self.pt_input.setValidator(doubleValidator)
        self.pu_input.setValidator(doubleValidator)
        self.ad2_max_input.setValidator(doubleValidator)
        self.pp_input.setValidator(doubleValidator)
        self.resulotion_input.setValidator(doubleValidator)
Пример #23
0
 def make_open_loop_controls(self):
     row_line = QLineEdit("", self)
     row_label = QLabel("Rows")
     col_line = QLineEdit("", self)
     col_label = QLabel("Columns")
     duration_line = QLineEdit("", self)
     duration_label = QLabel("Duration")
     interval_line = QLineEdit("", self)
     interval_label = QLabel("Interval")
     double_validator = QDoubleValidator()
     double_validator.setNotation(QDoubleValidator.StandardNotation)
     duration_line.setValidator(double_validator)
     interval_line.setValidator(double_validator)
     row_line.returnPressed.connect(lambda: self.update_setting("rows", int(row_line.text())))
     col_line.returnPressed.connect(lambda: self.update_setting("cols", int(col_line.text())))
     duration_line.returnPressed.connect(lambda: self.update_setting("duration_s", duration_line.text()))
     interval_line.returnPressed.connect(lambda: self.update_setting("interval_s", interval_line.text()))
     self.open_loop_labels = [row_label, col_label, duration_label, interval_label]
     self.open_loop_lines = [row_line, col_line, duration_line, interval_line]
     keys = ["rows", "cols", "duration_s", "interval_s"]
     control_layout = QHBoxLayout()
     for label, line, key in zip(self.open_loop_labels, self.open_loop_lines, keys):
         label.setAlignment(Qt.AlignCenter)
         line.setPlaceholderText(str(self.settings_dict[key]))
         layout = QVBoxLayout()
         layout.addWidget(label)
         layout.addWidget(line)
         layout.setSpacing(0)
         control_layout.addLayout(layout)
     self.window_layout.addLayout(control_layout)
Пример #24
0
    def initGUI(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("请输入数字和字母")

        intValidator = QIntValidator(self)
        intValidator.setRange(1, 10)

        doubleValidator = QDoubleValidator(self)
        doubleValidator.setRange(-180, 180)
        doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        # 小数点后两位
        doubleValidator.setDecimals(2)

        reg = QRegExp('[a-zA-Z0-9]+$')
        regValidator = QRegExpValidator(self)
        regValidator.setRegExp(reg)

        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(doubleValidator)
        validatorLineEdit.setValidator(regValidator)

        self.setLayout(formlayout)
Пример #25
0
    def __init__(self, parent=None):
        super(Heater, self).__init__(parent)
        self.setupUi(self)

        self.heater_number_input.setValidator(
            QIntValidator(1, 20, self.heater_number_input))

        self.heater_number_input.textChanged[str].connect(self.heaterNumber)
        self.okButton.clicked.connect(self.okbutton)
        self.cancelButton.clicked.connect(self.cancelbutton)
        self.clearButton.clicked.connect(self.data.clear)

        burner_efficiency_validator = QDoubleValidator(
            0, 99, 2, self.burner_efficiency_input)
        burner_efficiency_validator.setNotation(
            QDoubleValidator.StandardNotation)
        self.burner_efficiency_input.setValidator(burner_efficiency_validator)

        self.burner_efficiency_input.textChanged[str].connect(
            self.burner_efficiency_change)

        self.burner_oxygen_percent_spinbox.valueChanged.connect(
            self.burner_spinbox_changed)
        self.burner_fluegas_spinbox.valueChanged.connect(
            self.burner_spinbox_changed)
Пример #26
0
 def ui(self):
     layout = QFormLayout(self)
     for k, v in self.parameters.items():
         if v['kind'] == ParameterDialog.ComboBox:
             comboBox = QComboBox()
             comboBox.addItems(v['items'])
             layout.addRow(k, comboBox)
         elif v['kind'] == ParameterDialog.FloatSlider:
             f = lambda n: v['min'] + n / 100 * (v['max'] - v['min'])
             g = lambda x: int((x - v['min']) / (v['max'] - v['min']) * 100)
             slider = QSlider(Qt.Horizontal)
             slider.setMinimum(0)
             slider.setMaximum(100)
             slider.setSingleStep(1)
             slider.setValue(g(v['init']))
             le = QLineEdit()
             le.setPlaceholderText(v['init'])
             dv = QDoubleValidator(self)
             dv.setRange(v['min'], v['max'])
             dv.setNotation(QDoubleValidator.StandardNotation)
             dv.setDecimals(2)
             le.setValidator(dv)
             # slider.valueChanged.connect(lambda n: le.setText(f(n)))
             # le.textChanged.connect(lambda x: slider.setValue(g(x)))
             hlayout = QHBoxLayout()
             hlayout.addWidget(slider, alignment=Qt.AlignLeft)
             hlayout.addWidget(le, alignment=Qt.AlignRight)
             layout.addRow(k, hlayout)
     self.setLayout(layout)
Пример #27
0
    def __init__(self, parent=None):
        super(MainWin, self).__init__(parent)

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

        flo.addRow('整數', pIntLineEdit)
        flo.addRow('浮點數', pDoubleLineEdit)
        flo.addRow('字母和數字', pValidatorLineEdit)

        pIntLineEdit.setPlaceholderText('整數')
        pDoubleLineEdit.setPlaceholderText('浮點數')
        pValidatorLineEdit.setPlaceholderText('字母和數字')

        pIntValidator = QIntValidator(self)
        pIntValidator.setRange(1, 99)

        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)
        self.setWindowTitle('QLineEdit範例')
Пример #28
0
    def initUI(self):
        self.setWindowTitle("Validator Demo")

        formlayout = QFormLayout()
        intLineEdit = QLineEdit()
        doubleLineEdit = QLineEdit()
        regExpLineEdit = QLineEdit()

        formlayout.addRow("Int Validator:", intLineEdit)
        formlayout.addRow("Double Validator:", doubleLineEdit)
        formlayout.addRow("RegExp Validator:", regExpLineEdit)

        intLineEdit.setPlaceholderText("Int Type")
        doubleLineEdit.setPlaceholderText("Double Type")
        regExpLineEdit.setPlaceholderText("Letters and numbers")

        intValidator = QIntValidator(1, 99, self)

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

        regExp = QRegExp("[a-zA-Z0-9]+$")
        regExpValidator = QRegExpValidator(regExp, self)

        intLineEdit.setValidator(intValidator)
        doubleLineEdit.setValidator(doubleValidator)
        regExpLineEdit.setValidator(regExpValidator)

        self.setLayout(formlayout)
Пример #29
0
    def __init__(self, parent=None):
        super(LineEditDemo, self).__init__(parent)
        self.setWindowTitle('QLineEdit Validator sample')

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

        flo.addRow('Integer', pIntLineEdit)
        flo.addRow('Float', pDoubleLineEdit)
        flo.addRow('Letter and number', pValidatorLineEdit)

        pIntLineEdit.setPlaceholderText('Integer')
        pDoubleLineEdit.setPlaceholderText('Float')
        pValidatorLineEdit.setPlaceholderText('Letter and number')

        pIntValidator = QIntValidator(self)
        pIntValidator.setRange(1, 99)

        pDoubleValidator = QDoubleValidator(self)
        pDoubleValidator.setRange(-100, 100)
        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)
Пример #30
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setFixedHeight(525)
        self.setupUi(self)
        #Init GUI elements
        validator = QDoubleValidator()
        validator.setNotation(QtGui.QDoubleValidator.StandardNotation)
        validator.setRange(0, 50.00, 2)
        self.pizzaPrice_LE_1.setValidator(validator)
        self.pizzaPrice_LE_2.setValidator(validator)
        self.pizzaPrice_LE_3.setValidator(validator)
        self.pizzaPrice_LE_4.setValidator(validator)
        self.pizza_round_label.setHidden(True)
        self.pizza_quad_label.setHidden(True)
        self.missing_Input_Label.setHidden(True)
        self.diagram_GV.setHidden(True)

        #signals (events)
        self.calculate_PB.clicked.connect(self.check_Inputs_AndCalc)
        self.clear_PB.clicked.connect(self.clear_all_LE)
        self.length_verticalSlider.valueChanged.connect(self.set_length)
        self.width_verticalSlider.valueChanged.connect(self.set_width)
        self.hiddenButton_PB.clicked.connect(self.show_images)
        self.diagram_PB.clicked.connect(self.show_diagram)

        self.diagram_GV.setBackground('#baa7ba')
        styles = {'color': 'y', 'font-size': '18px'}
        self.diagram_GV.setLabel('left', 'rel. Preis [Cent/cm²]', **styles)
        self.diagram_GV.setLabel('bottom', 'Pizzafläche [cm²]', **styles)
        pen = pg.mkPen(color=(0, 0, 0), width=1)
        self.diagram_GV.plotItem.getAxis('left').setPen(pen)
        self.diagram_GV.plotItem.getAxis('left').setTextPen(pen)
        self.diagram_GV.plotItem.getAxis('bottom').setPen(pen)
        self.diagram_GV.plotItem.getAxis('bottom').setTextPen(pen)
Пример #31
0
    def openAmplitudeWindow(self, cm, sector):
        # type: (str, int) -> None

        # Put this here to speed things up (it was suuuuuuuper slow trying to do
        # this on startup)
        if cm not in self.buttonDisplays:
            displayCM = Display(ui_filename=self.pathToAmplitudeWindow,
                                macros={
                                    "cm": cm,
                                    "area": "L{SECTOR}B".format(SECTOR=sector)
                                })
            repeater = displayCM.ui.cavityRepeater

            lineEdits = []
            groupBoxes = []
            amaxLabels = []

            for cav in range(8):
                item = repeater.layout().itemAt(cav)  # type: QWidgetItem
                displayCav = item.widget()  # type: Display

                lineEdit = displayCav.ui.desiredAmplitude  # type: QLineEdit
                validator = QDoubleValidator(0.0, 21.0, 2, lineEdit)
                validator.setNotation(QDoubleValidator.StandardNotation)
                lineEdit.setValidator(validator)
                amaxLabel = displayCav.ui.amaxLabel

                try:
                    maxAmplitude = float(amaxLabel.text())
                except (TypeError, ValueError):
                    maxAmplitude = 0

                lineEdit.setText(str(maxAmplitude))
                lineEdit.textChanged.connect(
                    partial(self.checkIfAllCavitiesAtDefault, cm))
                lineEdits.append(lineEdit)

                groupBox = displayCav.ui.cavityGroupbox  # type: QGroupBox
                groupBox.toggled.connect(partial(self.cavityToggled, cm))
                groupBoxes.append(groupBox)

                amaxLabels.append(amaxLabel)

                restoreDefaultButton: QPushButton = displayCav.ui.restoreDefaultButton
                restoreDefaultButton.clicked.connect(
                    partial(self.restoreDefault, lineEdit,
                            displayCav.ui.amaxLabel))

            self.desiredCavAmpLineEdits[cm] = lineEdits
            self.buttonDisplays[cm] = displayCM
            self.cavityGroupBoxes[cm] = groupBoxes
            self.maxAmplitudeLabels[cm] = amaxLabels

            selectAllCheckbox = displayCM.ui.selectAllCheckbox  # type: QCheckBox
            self.selectAllCavitiesCheckboxes[cm] = selectAllCheckbox
            selectAllCheckbox.stateChanged.connect(
                partial(self.selectAllCavitiesToggled, cm))

        self.buttonDisplays[cm].show()
Пример #32
0
 def set_validator(self):
     doubleValitor = QDoubleValidator()
     doubleValitor.setBottom(0)
     doubleValitor.setDecimals(2)
     doubleValitor.setNotation(QDoubleValidator.StandardNotation)
     self.lineEdit_width.setValidator(doubleValitor)
     self.lineEdit_height.setValidator(doubleValitor)
     self.lineEdit_pensize.setValidator(doubleValitor)
Пример #33
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)