예제 #1
0
파일: p10.py 프로젝트: DK-afei/python
    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)
예제 #2
0
    def init_lineedit_content(self):
        # 入职前工作年限,格式应该为纯数字
        double_valitor = QDoubleValidator()
        double_valitor.setRange(0, 100)
        double_valitor.setDecimals(1)
        self.strongsuit.setValidator(double_valitor)

        # 出生日期、雇佣日期,格式yyyy-MM-DD
        reg = QRegExp('^[23][0-9]{3}-[0-9]{2}-[0-9]{2}$')
        day_validator = QRegExpValidator()
        day_validator.setRegExp(reg)
        self.birthday.setValidator(day_validator)
        self.entranceday.setValidator(day_validator)

        # 匹配身份证
        reg = QRegExp('^\d{17}(\d|X)$')
        id_validator = QRegExpValidator()
        id_validator.setRegExp(reg)
        self.idno.setValidator(id_validator)

        # 匹配电话号码,纯数字
        reg = QRegExp('[0-9]{11}')
        tel_validator = QRegExpValidator()
        tel_validator.setRegExp(reg)
        self.telno.setValidator(tel_validator)
    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)
예제 #4
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)
예제 #5
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)
예제 #6
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)
예제 #7
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()
    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 set_validator(self):

        doubleValitor = QDoubleValidator()
        doubleValitor.setBottom(0)
        doubleValitor.setDecimals(2)
        doubleValitor.setNotation(QDoubleValidator.StandardNotation)
        self.planamount.setValidator(doubleValitor)
    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)
예제 #11
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)
예제 #12
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)
예제 #13
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)
예제 #14
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)
예제 #15
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)
    def setUI(self):
        self.setWindowTitle("校验器")
        formlayout = QFormLayout()
        gridlayout = QGridLayout()
        # intlineEdit = QIntValidator()
        # doublelineEdit = QDoubleValidator()
        # reglineEdit = QRegExpValidator()

        intlineEdit = QLineEdit()
        doublelineEdit = QLineEdit()
        reglineEdit = QLineEdit()

        # 设定校验器
        IntValidator = QIntValidator(self)
        IntValidator.setRange(1, 99)
        DoubleValidator = QDoubleValidator(self)
        DoubleValidator.setDecimals(2)
        RegExpValidator = QRegExpValidator(self)
        reg = QRegExp("[A-Za-z0-9]+")
        RegExpValidator.setRegExp(reg)

        intlineEdit.setValidator(IntValidator)
        doublelineEdit.setValidator(DoubleValidator)
        reglineEdit.setValidator(RegExpValidator)

        formlayout.addRow("int", intlineEdit)
        formlayout.addRow("double", doublelineEdit)
        formlayout.addRow("reg", reglineEdit)

        self.setLayout(formlayout)
예제 #17
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)
예제 #18
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)
예제 #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
    def initUI(self):
        formLayout = QFormLayout()
        intLine = QLineEdit()
        doubletLine = QLineEdit()
        validatortLine = QLineEdit()

        formLayout.addRow("int", intLine)
        formLayout.addRow("double", doubletLine)
        formLayout.addRow("字母数字", validatortLine)

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

        # 浮点,小数点后两位
        doubleValidator = QDoubleValidator()
        doubleValidator.setRange(1, 99)
        # doubleValidator.setNotation(QDoubleValidator.StandardNotation)
        # 精度,小数点两位
        doubleValidator.setDecimals(2)
        # 数字字符
        reg = QRegExp('[a-zA-Z0-9]+$')
        validator = QRegExpValidator()
        validator.setRegExp(reg)

        intLine.setValidator(intValidator)
        doubletLine.setValidator(doubleValidator)
        validatortLine.setValidator(validator)

        self.setLayout(formLayout)
예제 #21
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)
예제 #22
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範例')
예제 #23
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)
예제 #24
0
    def setupUi(self, MainWindow):
        self.setWindowTitle('Клиент')
        self.setFixedSize(280, 220)
        # Set the central widget and the general layout
        self.generalLayout = QVBoxLayout()
        self._centralWidget = QWidget(self)
        self.setCentralWidget(self._centralWidget)
        self._centralWidget.setLayout(self.generalLayout)
        # label rate text
        self.label_rate = QLabel(self)
        self.label_rate.setText('Cтавка \nдисконтирования')
        self.label_rate.move(20, 55)
        self.label_rate.setAlignment(Qt.AlignCenter)

        # value rate line
        self.value_line_edit_rate = QLineEdit(self)
        self.value_line_edit_rate.move(120, 60)
        self.value_line_edit_rate.setText('0.2')
        self.value_line_edit_rate.adjustSize()
        self.value_line_edit_rate.setMaxLength(8)
        pDoubleValidator = QDoubleValidator(self)
        pDoubleValidator.setNotation(QDoubleValidator.StandardNotation)
        pDoubleValidator.setDecimals(4)
        self.value_line_edit_rate.setValidator(pDoubleValidator)

        # label year text
        self.label_year = QLabel(self)
        self.label_year.setText('Год')
        self.label_year.move(20, 85)
        self.label_year.setAlignment(Qt.AlignCenter)
        # value year text
        self.value_line_edit_year = QLineEdit(self)
        self.value_line_edit_year.move(120, 90)
        self.value_line_edit_year.setText('2050')
        self.value_line_edit_year.adjustSize()
        self.value_line_edit_year.setMaxLength(4)
        pIntValidator = QIntValidator(self)
        #pIntValidator.setRange(2020, 2050)
        self.value_line_edit_year.setValidator(pIntValidator)

        # button
        self.button = QPushButton('Расчёт', self)
        #self.button.clicked.connect(self.button1_clicked)
        self.button.resize(200, 32)
        self.button.move(50, 120)

        # Display
        self.display = QLineEdit(self)
        self.display.move(50, 10)
        self.display.resize(200, 32)
        self.display.setAlignment(Qt.AlignLeft)
        self.display.setReadOnly(True)

        # Предупреждение о диапазоне
        self.warning = QLabel(self)
        self.warning.setText('Диапазон:\nГод = [2020,2050], Ставка = [0,1]')
        self.warning.move(30, 170)
        self.warning.resize(200, 40)
class AttributeItemWidget(QWidget):

    item_changed = pyqtSignal(name='items_changed')

    def __init__(self, label_text, value, editable):
        super().__init__()

        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)

        self._value = value
        self._is_bool = isinstance(value, bool)

        self.label = QLabel(label_text)
        if isinstance(self._value, bool):
            self.value_field = QCheckBox()
            self.value_field.setChecked(self._value)
            self.value_field.setCheckable(~editable)
            self.value_field.clicked.connect(self.emit_field_changed)
        else:
            self.value_field = QLineEdit(str(self._value))
            self.value_field.setReadOnly(editable)
            self.value_field.setAlignment(Qt.AlignCenter)
            self.value_field.returnPressed.connect(self.emit_field_changed)
            if isinstance(self._value, int):
                self.int_validator = QIntValidator(self)
                self.value_field.setValidator(self.int_validator)
            elif isinstance(self._value, float):
                self.double_validator = QDoubleValidator(self)
                self.double_validator.setDecimals(5)
                self.value_field.setValidator(self.double_validator)

        self.setLayout(self.layout)

        self.label.setFixedWidth(150)

        self.layout.addWidget(self.label)
        self.layout.addWidget(self.value_field)
        self.layout.addStretch()

    @property
    def value(self):
        return self._value

    @value.setter
    def value(self, value):
        if self._is_bool:
            self.value_field.setChecked(value)
        else:
            self.value_field.setText(str(value))

    def emit_field_changed(self):
        if self._is_bool:
            self._value = self.value_field.isChecked()
        else:
            self._value = self.value_field.text()
        self.item_changed.emit()
예제 #26
0
 def _createValidator(self):
     validator = QDoubleValidator(self.parent)
     if "min" in self.config:
         validator.setBottom(int(self.config["min"]))
     if "max" in self.config:
         validator.setTop(int(self.config["max"]))
     if "decimals" in self.config:
         validator.setDecimals(int(self.config["decimals"]))
     return validator
 def set_validator(self):
     doubleValitor = QDoubleValidator()
     doubleValitor.setBottom(-1)
     doubleValitor.setDecimals(3)
     doubleValitor.setNotation(QDoubleValidator.StandardNotation)
     self.lineEdit_content.setValidator(doubleValitor)
     self.lineEdit_water.setValidator(doubleValitor)
     self.lineEdit_rdensity.setValidator(doubleValitor)
     self.lineEdit_impurity.setValidator(doubleValitor)
예제 #28
0
    def FormVendas(self):
        self.DesativaBotaoVendas()
        self.LimpaFrame(self.ct_containerVendas)
        super(MainVendas, self).setFormVendas(self.ct_containerVendas)
        self.fr_FormVendas.show()

        # Checando se existe ID válido
        self.IdCheckVenda()
        # Icone Botoes
        self.IconeBotaoMenu(self.bt_BuscaVendas,
                            self.resourcepath('Images/iconSearch.png'))

        # Validar campos int
        validarInt = QIntValidator(0, 999, self)
        # Validar campos float
        validarValorFloat = QDoubleValidator(0.50, 999.99, 2, self)
        validarValorFloat.setNotation(QDoubleValidator.StandardNotation)
        validarValorFloat.setDecimals(2)

        self.tx_QtdItem.setValidator(validarInt)
        self.tx_ValorUnitarioItem.setValidator(validarValorFloat)
        self.tx_ValorTotalItem.setValidator(validarValorFloat)
        self.tx_SubTotal.setValidator(validarValorFloat)
        self.tx_Desconto.setValidator(validarValorFloat)
        self.tx_TotalFinal.setValidator(validarValorFloat)

        # Botao Add Categoria e populando combobox e check
        self.ListaTipoPagamento()
        # busca cliente e produto
        self.tx_IdCliente.returnPressed.connect(self.BuscaClienteId)
        self.tx_IdCliente.textEdited.connect(self.BuscaClienteId)
        self.tx_IdBuscaItem.returnPressed.connect(self.BuscaProdutoId)
        self.tx_IdBuscaItem.textEdited.connect(self.BuscaProdutoId)
        # calculo total item
        self.tx_QtdItem.returnPressed.connect(self.TotalItem)
        self.tx_QtdItem.textEdited.connect(self.TotalItem)
        # Calculo valor final da venda
        self.tx_Desconto.returnPressed.connect(self.TotalFinal)
        self.tx_Desconto.textEdited.connect(self.TotalFinal)
        # Add item no carrinho de compra
        self.bt_IncluirItem.clicked.connect(self.ValidaDadosAddItem)
        # acoes
        self.bt_Voltar.clicked.connect(self.janelaVendas)
        self.bt_Salvar.clicked.connect(self.ValidarDadosVenda)

        self.tb_Itens.blockSignals(True)
        self.tb_Itens.setColumnHidden(0, True)
        self.tb_Itens.resizeRowsToContents()
        self.tb_Itens.setColumnWidth(1, 100)
        self.tb_Itens.setColumnWidth(2, 100)
        self.tb_Itens.setColumnWidth(3, 100)
        self.tb_Itens.setColumnWidth(4, 100)
        self.tb_Itens.setColumnWidth(5, 100)
        self.tb_Itens.setColumnWidth(6, 100)
예제 #29
0
 def createEditor(self, parent: QWidget, option: QStyleOptionViewItem,
                  index: QModelIndex) -> QWidget:
     wdgt = QLineEdit(parent)
     wdgt.setAttribute(Qt.WA_InputMethodEnabled, False)
     if self.__ValueType == JPFieldType.Int:
         wdgt.setValidator(QIntValidator())
     if self.__ValueType == JPFieldType.Float:
         va = QDoubleValidator()
         va.setDecimals(self.__Decimal)
         wdgt.setValidator(va)
     return wdgt
예제 #30
0
    def __init__(self, parent):
        super(AddCargoTypeDialog, self).__init__(parent)
        self.setupUi(self)

        double_val = QDoubleValidator(self)
        double_val.setBottom(0)
        double_val.setDecimals(2)
        self.price.setValidator(double_val)

        int_val = QIntValidator(self)
        int_val.setBottom(0)
        self.life.setValidator(int_val)
예제 #31
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)                        
예제 #32
-1
 def __init__ (self, parent):
     super().__init__(parent)
     self.setEnabled(False)
     layout = QFormLayout(self)
     
     l_persistence = QLabel("&Persistence", self)
     persistence = QComboBox(self)
     persvals = ("", "Mark", "OnceEver", "OncePerConv")
     persistence.insertItems(len(persvals), persvals)
     persistence.currentTextChanged.connect(self.persistencechanged)
     l_persistence.setBuddy(persistence)
     self.persistence = persistence
     
     l_bankmode = QLabel("&Bank play mode", self)
     bankmode = QComboBox(self)
     bankmodes = ("First", "All", "Append")
     bankmode.insertItems(len(bankmodes), bankmodes)
     bankmode.currentTextChanged.connect(self.bankmodechanged)
     l_bankmode.setBuddy(bankmode)
     self.bankmode = bankmode
     
     l_questionhub = QLabel("&Question hub", self)
     questionhub = QComboBox(self)
     qhubtypes = ("", "ShowOnce", "ShowNever")
     questionhub.insertItems(len(qhubtypes), qhubtypes)
     questionhub.currentTextChanged.connect(self.questionhubchanged)
     l_questionhub.setBuddy(questionhub)
     self.questionhub = questionhub
     
     l_trigger = QLabel("&Trigger conversation", self)
     trigger = QComboBox(self)
     trigger.currentTextChanged.connect(self.triggerchanged)
     l_trigger.setBuddy(trigger)
     self.trigger = trigger
     
     l_randweight = QLabel("&Random weight", self)
     randweight = QLineEdit(self)
     rwvalidator = QDoubleValidator(self)
     rwvalidator.setBottom(0)
     rwvalidator.setDecimals(3)
     randweight.setValidator(rwvalidator)
     randweight.editingFinished.connect(self.randweightchanged)
     l_randweight.setBuddy(randweight)
     self.randweight = randweight
     
     l_comment = QLabel("&Comment", self)
     comment = ParagraphEdit(self)
     comment.textChanged.connect(self.commentchanged)
     self.comment = comment
     l_comment.setBuddy(comment)
     
     layout.addRow(l_persistence, persistence)
     layout.addRow(l_bankmode, bankmode)
     layout.addRow(l_questionhub, questionhub)
     layout.addRow(l_trigger, trigger)
     layout.addRow(l_randweight, randweight)
     layout.addRow(l_comment, comment)
     
     textdoc = QTextDocument(self)
     textdoc.setDocumentLayout(QPlainTextDocumentLayout(textdoc))
     self.blankdoc = textdoc