本文整理汇总了Python中PyQt5.QtCore.QRegExp方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QRegExp方法的具体用法?Python QtCore.QRegExp怎么用?Python QtCore.QRegExp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QRegExp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: searchFor
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def searchFor(self, searchCommand: str):
regex = QRegExp(searchCommand)
index = find_all(self.editor.toPlainText(), searchCommand)
a = list(index)
textCursor = self.editor.textCursor()
try:
textCursor.setPosition(a[0])
textCursor.movePosition(
textCursor.Right, textCursor.KeepAnchor, regex.matchedLength()
)
self.editor.setTextCursor(textCursor)
except Exception as E:
pass
示例2: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [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)
示例3: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [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)
示例4: at_time
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [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)
示例5: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [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()
示例6: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def __init__(self, document):
QSyntaxHighlighter.__init__(self, document)
rules = []
rules += [
(r'\[.*\] ', 0, self.STYLES['tstamp']),
(r'\s.*(stat|tele).*\s', 0, self.STYLES['brace']),
(r'\s.*cmnd.*\s', 0, self.STYLES['command']),
(r'\"\w*\"(?=:)', 0, self.STYLES['keyword']),
(r':\"\w*\"', 0, self.STYLES['error']),
(r'\{\"Command\":\"Unknown\"\}', 0, self.STYLES['error']),
]
rules += [(r'%s' % b, 0, self.STYLES['brace']) for b in self.braces]
self.rules = [(QRegExp(pat), index, fmt) for (pat, index, fmt) in rules]
示例7: filterRegExpChanged
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def filterRegExpChanged(self, value):
regExp = QtCore.QRegExp(value)
self.xrefwindow.proxyModel.setFilterRegExp(regExp)
示例8: filterRegExpChanged
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def filterRegExpChanged(self, value):
regExp = QtCore.QRegExp(value)
self.stringswindow.proxyModel.setFilterRegExp(regExp)
示例9: filterRegExpChanged
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def filterRegExpChanged(self, value):
regExp = QtCore.QRegExp(value)
self.resourceswindow.proxyModel.setFilterRegExp(regExp)
示例10: filterRegExpChanged
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def filterRegExpChanged(self, value):
regExp = QtCore.QRegExp(value)
self.methodswindow.proxyModel.setFilterRegExp(regExp)
示例11: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def __init__(self, parent=None):
super(Highlighter, self).__init__(parent)
keywordFormat = QtGui.QTextCharFormat()
keywordFormat.setForeground(QtCore.Qt.blue)
keywordFormat.setFontWeight(QtGui.QFont.Bold)
keywordPatterns = ["\\b{}\\b".format(k) for k in keyword.kwlist]
self.highlightingRules = [(QtCore.QRegExp(pattern), keywordFormat)
for pattern in keywordPatterns]
classFormat = QtGui.QTextCharFormat()
classFormat.setFontWeight(QtGui.QFont.Bold)
self.highlightingRules.append((QtCore.QRegExp("\\bQ[A-Za-z]+\\b"),
classFormat))
singleLineCommentFormat = QtGui.QTextCharFormat()
singleLineCommentFormat.setForeground(QtCore.Qt.gray)
self.highlightingRules.append((QtCore.QRegExp("#[^\n]*"),
singleLineCommentFormat))
quotationFormat = QtGui.QTextCharFormat()
quotationFormat.setForeground(QtCore.Qt.darkGreen)
self.highlightingRules.append((QtCore.QRegExp("\".*\""),
quotationFormat))
self.highlightingRules.append((QtCore.QRegExp("'.*'"),
quotationFormat))
示例12: highlightBlock
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def highlightBlock(self, text):
for pattern, format in self.highlightingRules:
expression = QtCore.QRegExp(pattern)
index = expression.indexIn(text)
while index >= 0:
length = expression.matchedLength()
self.setFormat(index, length, format)
index = expression.indexIn(text, index + length)
self.setCurrentBlockState(0)
示例13: set_pattern
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def set_pattern(self, val):
"""Setter for pattern.
Args:
val: The value to set.
"""
self._pattern = val
val = re.sub(r' +', r' ', val) # See #1919
val = re.escape(val)
val = val.replace(r'\ ', '.*')
rx = QRegExp(val, Qt.CaseInsensitive)
self.setFilterRegExp(rx)
self.invalidate()
sortcol = 0
self.sort(sortcol)
示例14: filter_table
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [as 别名]
def filter_table(self, text):
reg_exp = QRegExp(text, Qt.CaseInsensitive)
self.setFilterRegExp(reg_exp)
示例15: validate_data
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QRegExp [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)