当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QRegExpValidator方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QRegExpValidator方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QRegExpValidator方法的具体用法?Python QtGui.QRegExpValidator怎么用?Python QtGui.QRegExpValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.QRegExpValidator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self):
        super(UserInfoDialog, self).__init__()
        loadUi('./ui/UserInfoDialog.ui', self)
        self.setWindowIcon(QIcon('./icons/icon.png'))
        self.setFixedSize(425, 300)

        # 使用正则表达式限制用户输入
        stu_id_regx = QRegExp('^[0-9]{12}$')
        stu_id_validator = QRegExpValidator(stu_id_regx, self.stuIDLineEdit)
        self.stuIDLineEdit.setValidator(stu_id_validator)

        cn_name_regx = QRegExp('^[\u4e00-\u9fa5]{1,10}$')
        cn_name_validator = QRegExpValidator(cn_name_regx, self.cnNameLineEdit)
        self.cnNameLineEdit.setValidator(cn_name_validator)

        en_name_regx = QRegExp('^[ A-Za-z]{1,16}$')
        en_name_validator = QRegExpValidator(en_name_regx, self.enNameLineEdit)
        self.enNameLineEdit.setValidator(en_name_validator) 
开发者ID:winterssy,项目名称:face_recognition_py,代码行数:20,代码来源:dataRecord.py

示例2: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self, parent=None):
        super(MachineSelector, self).__init__(parent)
        box = QtWidgets.QHBoxLayout(self)
        label = MonitoringLabel('List of &machines (threads)')
        self.is_ready = label.is_ready
        self.updated = label.updated
        box.addWidget(label)
        self._machines = QtWidgets.QLineEdit('all')
        self._machines.setToolTip('an integer, \
        a comma-separated list of integers, or "all"')
        grammar = QRegExp(r'\s*(all|\d+\s*(,\s*\d+\s*)*)\s*')
        valid = QtGui.QRegExpValidator(grammar)
        self._machines.setValidator(valid)
        label.setBuddy(self._machines)
        box.addWidget(self._machines)
        box.addStretch(1)
        self.setLayout(box) 
开发者ID:BinaryAnalysisPlatform,项目名称:bap-ida-python,代码行数:19,代码来源:bap_trace.py

示例3: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self, min_, max_, float_=False):
        super(QwordSpinBox, self).__init__()

        self._minimum = min_
        self._maximum = max_
        self.int_ = float if float_ else int

        rx = QRegExp('-?\d{0,20}(?:\.\d{0,20})?' if float_ else '-?\d{0,20}')
        validator = QRegExpValidator(rx, self)

        self._lineEdit = QLineEdit(self)
        self._lineEdit.setText(str(self.int_(0)))
        self._lineEdit.setValidator(validator)
        self._lineEdit.textEdited.connect(partial(self.setValue, change=False))
        self.editingFinished.connect(lambda: self.setValue(self.value(), update=False) or True)
        self.setLineEdit(self._lineEdit) 
开发者ID:marin-m,项目名称:pbtk,代码行数:18,代码来源:fuzzer.py

示例4: at_time

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def at_time(self):

        logging.debug('at_time() called')

        self.at_time_input = QWidget()
        self.at_time_layout = QVBoxLayout(self.at_time_input)

        self.time_text = QLabel()
        self.time_text.setText(QC.translate('', 'At:'))

        self.time_input = QLineEdit()
        regexp_validator = QRegExp('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$')
        self.time_validator = QRegExpValidator(regexp_validator)
        self.time_input.setValidator(self.time_validator)
        self.time_input.setPlaceholderText(QC.translate('', 'hh:mm'))

        self.at_time_layout.addWidget(self.time_text)
        self.at_time_layout.addWidget(self.time_input)

        self.at_time_input.hide()
        self.options_box_layout.addWidget(self.at_time_input) 
开发者ID:hANSIc99,项目名称:Pythonic,代码行数:23,代码来源:basic_sched.py

示例5: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self, checksum_label: ChecksumLabel, message: Message, proto_view: int, parent=None):
        super().__init__(parent)
        self.ui = Ui_ChecksumOptions()
        self.ui.setupUi(self)
        self.checksum_label = checksum_label
        self.data_range_table_model = self.RangeTableModel(checksum_label, message, proto_view, parent=self)
        self.ui.tableViewDataRanges.setItemDelegateForColumn(0, SpinBoxDelegate(1, 999999, self))
        self.ui.tableViewDataRanges.setItemDelegateForColumn(1, SpinBoxDelegate(1, 999999, self))
        self.ui.tableViewDataRanges.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.ui.tableViewDataRanges.setModel(self.data_range_table_model)
        self.ui.tableViewDataRanges.setEditTriggers(QAbstractItemView.AllEditTriggers)
        self.display_crc_data_ranges_in_table()
        self.ui.comboBoxCRCFunction.addItems([crc_name for crc_name in GenericCRC.DEFAULT_POLYNOMIALS])
        self.ui.comboBoxCRCFunction.addItems([special_crc_name for special_crc_name in self.SPECIAL_CRCS])
        self.ui.lineEditCRCPolynomial.setValidator(QRegExpValidator(QRegExp("[0-9,a-f]*")))
        self.ui.comboBoxCategory.clear()
        for _, member in self.checksum_label.Category.__members__.items():
            self.ui.comboBoxCategory.addItem(member.value)
        self.set_ui_for_category()
        self.setFocus()
        self.create_connects() 
开发者ID:jopohl,项目名称:urh,代码行数:23,代码来源:ChecksumWidget.py

示例6: validate_data

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def validate_data(self, reg_exp, field_name):
        field = getattr(self, field_name)
        reg_ex = QRegExp(reg_exp)
        input_validator = QRegExpValidator(reg_ex, field)
        field.setValidator(input_validator) 
开发者ID:frappe,项目名称:biometric-attendance-sync-tool,代码行数:7,代码来源:gui.py

示例7: createEditor

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def createEditor(self, parent, option, index):
        if index.column() < 4:
            self.editor = QtWidgets.QComboBox(parent)
            self.editor.addItems(self.items[index.column()])
        else:
            self.editor = QtWidgets.QLineEdit(parent)
            regExp = QtCore.QRegExp("[A-Z]{1,3}\\d{1,5}")
            validator = QtGui.QRegExpValidator(regExp)
            self.editor.setValidator(validator)
        return self.editor 
开发者ID:jjgomera,项目名称:pychemqt,代码行数:12,代码来源:UI_spreadsheet.py

示例8: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self):
        super(TelegramBotDialog, self).__init__()
        loadUi('./ui/TelegramBotDialog.ui', self)
        self.setWindowIcon(QIcon('./icons/icon.png'))
        self.setFixedSize(550, 358)

        chat_id_regx = QRegExp('^\d+$')
        chat_id_validator = QRegExpValidator(chat_id_regx, self.telegramIDLineEdit)
        self.telegramIDLineEdit.setValidator(chat_id_validator)

        self.okButton.clicked.connect(self.telegramBotSettings) 
开发者ID:winterssy,项目名称:face_recognition_py,代码行数:13,代码来源:core.py

示例9: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self, plugin):
        super(CreateProjectDialog, self).__init__()
        self._plugin = plugin

        # General setup of the dialog
        self._plugin.logger.debug("Create project dialog")
        self.setWindowTitle("Create Project")
        icon_path = plugin.plugin_resource("upload.png")
        self.setWindowIcon(QIcon(icon_path))
        self.resize(100, 100)

        # Set up the layout and widgets
        layout = QVBoxLayout(self)

        self._nameLabel = QLabel("<b>Project Name</b>")
        layout.addWidget(self._nameLabel)
        self._nameEdit = QLineEdit()
        self._nameEdit.setValidator(QRegExpValidator(QRegExp("[a-zA-Z0-9-]+")))
        layout.addWidget(self._nameEdit)

        buttons = QWidget(self)
        buttons_layout = QHBoxLayout(buttons)
        create_button = QPushButton("Create")
        create_button.clicked.connect(self.accept)
        buttons_layout.addWidget(create_button)
        cancel_button = QPushButton("Cancel")
        cancel_button.clicked.connect(self.reject)
        buttons_layout.addWidget(cancel_button)
        layout.addWidget(buttons) 
开发者ID:IDArlingTeam,项目名称:IDArling,代码行数:31,代码来源:dialogs.py

示例10: time_between

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def time_between(self):

        logging.debug('time_between() called')
        self.time_between_input = QWidget()
        self.time_between_layout = QVBoxLayout(self.time_between_input)

        self.time_between_txt = QLabel()
        self.time_between_txt.setText(QC.translate('', 'Between'))

        regexp_validator = QRegExp('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$')
        self.time_validator = QRegExpValidator(regexp_validator)

        self.time_row = QWidget()
        self.time_row_layout = QHBoxLayout(self.time_row)

        self.start_time_input = QLineEdit()
        self.start_time_input.setValidator(self.time_validator)
        self.start_time_input.setPlaceholderText(QC.translate('', 'hh:mm (default 00:00)'))

        self.and_text = QLabel()
        self.and_text.setText(QC.translate('', 'and'))

        self.stop_time_input = QLineEdit()
        self.stop_time_input.setValidator(self.time_validator)
        self.stop_time_input.setPlaceholderText(QC.translate('', 'hh:mm (default 00:00)'))

        
        self.time_row_layout.addWidget(self.start_time_input)
        self.time_row_layout.addWidget(self.and_text)
        self.time_row_layout.addWidget(self.stop_time_input)


        self.time_between_layout.addWidget(self.time_between_txt)
        self.time_between_layout.addWidget(self.time_row)

        self.time_between_input.hide()

        self.options_box_layout.addWidget(self.time_between_input) 
开发者ID:hANSIc99,项目名称:Pythonic,代码行数:40,代码来源:basic_sched.py

示例11: set_re_float

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def set_re_float(line_edit):
    line_edit.setValidator(QRegExpValidator(QRegExp('^\d*\.?\d+$'), line_edit))
# TODO: add regex also for asset id 
开发者ID:Blockstream,项目名称:liquid-swap,代码行数:5,代码来源:app.py

示例12: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self,parent = None, aw = None, values = [0,0]):
        super(pointDlg,self).__init__(parent, aw)
        self.values = values
        self.setWindowTitle(QApplication.translate("Form Caption","Add Point",None))
        self.tempEdit = QLineEdit(str(int(round(self.values[1]))))
        self.tempEdit.setValidator(QIntValidator(0, 999, self.tempEdit))
        self.tempEdit.setFocus()
        self.tempEdit.setAlignment(Qt.AlignRight)
        templabel = QLabel(QApplication.translate("Label", "temp",None))
        regextime = QRegExp(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$")
        self.timeEdit = QLineEdit(stringfromseconds(self.values[0],leadingzero=False))
        self.timeEdit.setAlignment(Qt.AlignRight)
        self.timeEdit.setValidator(QRegExpValidator(regextime,self))
        timelabel = QLabel(QApplication.translate("Label", "time",None))

        # connect the ArtisanDialog standard OK/Cancel buttons
        self.dialogbuttons.accepted.connect(self.return_values)
        self.dialogbuttons.rejected.connect(self.reject)
        
        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch()
        buttonLayout.addWidget(self.dialogbuttons)
        grid = QGridLayout()
        grid.addWidget(timelabel,0,0)
        grid.addWidget(self.timeEdit,0,1)
        grid.addWidget(templabel,1,0)
        grid.addWidget(self.tempEdit,1,1)
        mainLayout = QVBoxLayout()
        mainLayout.addLayout(grid)
        mainLayout.addStretch()  
        mainLayout.addLayout(buttonLayout)
        self.setLayout(mainLayout)
        self.dialogbuttons.button(QDialogButtonBox.Ok).setFocus() 
开发者ID:artisan-roaster-scope,项目名称:artisan,代码行数:35,代码来源:designer.py

示例13: createsegmenttable

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def createsegmenttable(self):
        self.segmenttable.setRowCount(8)
        self.segmenttable.setColumnCount(4)
        self.segmenttable.setHorizontalHeaderLabels([QApplication.translate("Table","SV",None),
                                                     QApplication.translate("Table","Ramp HH:MM",None),
                                                     QApplication.translate("Table","Soak HH:MM",None),""])
        self.segmenttable.setEditTriggers(QTableWidget.NoEditTriggers)
        self.segmenttable.setSelectionBehavior(QTableWidget.SelectRows)
        self.segmenttable.setSelectionMode(QTableWidget.SingleSelection)
        self.segmenttable.setShowGrid(True)
        self.segmenttable.verticalHeader().setSectionResizeMode(2)
        regextime = QRegExp(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$")
        #populate table
        for i in range(8):
            #create widgets
            svkey = "segment" + str(i+1) + "sv"
            rampkey = "segment" + str(i+1) + "ramp"
            soakkey = "segment" + str(i+1) + "soak"
            
            svedit = QLineEdit(str(self.aw.fujipid.PXR[svkey][0]))
            svedit.setValidator(self.aw.createCLocaleDoubleValidator(0., 999., 1, svedit))
            rampedit = QLineEdit(stringfromseconds(self.aw.fujipid.PXR[rampkey][0]))
            rampedit.setValidator(QRegExpValidator(regextime,self))
            soakedit  = QLineEdit(stringfromseconds(self.aw.fujipid.PXR[soakkey][0]))
            soakedit.setValidator(QRegExpValidator(regextime,self))
            setButton = QPushButton(QApplication.translate("Button","Set",None))
            setButton.clicked.connect(self.setsegment)
            setButton.setFocusPolicy(Qt.NoFocus)
            #add widgets to the table
            self.segmenttable.setCellWidget(i,0,svedit)
            self.segmenttable.setCellWidget(i,1,rampedit)
            self.segmenttable.setCellWidget(i,2,soakedit)
            self.segmenttable.setCellWidget(i,3,setButton)

    #idn = id number, sv = float set value, ramp = ramp value, soak = soak value 
开发者ID:artisan-roaster-scope,项目名称:artisan,代码行数:37,代码来源:pid_dialogs.py

示例14: update_modulation_parameters

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def update_modulation_parameters(self):
        n = len(self.current_modulator.parameters) - 1
        if self.current_modulator.is_amplitude_based:
            regex = r"(100|[0-9]{1,2})"
        elif self.current_modulator.is_frequency_based:
            regex = r"((-?[0-9]+)[.,]?[0-9]*[kKmMgG]?)"
        elif self.current_modulator.is_phase_based:
            regex = r"(-?(36[0]|3[0-5][0-9]|[12][0-9][0-9]|[1-9]?[0-9]))"
        else:
            raise ValueError("Unknown modulation type")

        full_regex = r"^(" + regex + r"/){" + str(n) + "}" + regex + r"$"
        self.ui.lineEditParameters.setValidator(QRegExpValidator(QRegExp(full_regex)))
        self.ui.lineEditParameters.setText(self.current_modulator.parameters_string) 
开发者ID:jopohl,项目名称:urh,代码行数:16,代码来源:ModulatorDialog.py

示例15: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegExpValidator [as 别名]
def __init__(self, project_manager: ProjectManager, is_tx: bool, backend_handler: BackendHandler = None,
                 continuous_send_mode=False, parent=None):
        super().__init__(parent)
        self.ui = Ui_FormDeviceSettings()
        self.ui.setupUi(self)

        self.__device = None  # type: VirtualDevice

        self.is_tx = is_tx
        self.is_rx = not is_tx
        if backend_handler is None:
            self.backend_handler = BackendHandler()
        else:
            self.backend_handler = backend_handler

        if self.is_rx:
            self.ui.spinBoxNRepeat.hide()
            self.ui.labelNRepeat.hide()
        else:
            self.ui.labelDCCorrection.hide()
            self.ui.checkBoxDCCorrection.hide()

        self.bw_sr_are_locked = settings.read("lock_bandwidth_sample_rate", True, bool)
        self.ui.cbDevice.clear()
        items = self.get_devices_for_combobox(continuous_send_mode)
        self.ui.cbDevice.addItems(items)
        self.bootstrap(project_manager.device_conf, enforce_default=True)

        self.ui.btnLockBWSR.setChecked(self.bw_sr_are_locked)
        self.on_btn_lock_bw_sr_clicked()

        ip_range = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"
        ip_regex = QRegExp("^" + ip_range
                           + "\\." + ip_range
                           + "\\." + ip_range
                           + "\\." + ip_range + "$")
        self.ui.lineEditIP.setValidator(QRegExpValidator(ip_regex))

        self.create_connects()
        self.sync_gain_sliders() 
开发者ID:jopohl,项目名称:urh,代码行数:42,代码来源:DeviceSettingsWidget.py


注:本文中的PyQt5.QtGui.QRegExpValidator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。