def __init__(self): super(trabajadores, self).__init__() self.ui = Ui_Dialog() self.ui.setupUi(self) self.Mtos = Metodos() self.data = [ le for le in self.findChildren(QLineEdit) if le.objectName() != "Le_Buscar"] self.current_id = 0 self.headerUsuarios = self.Mtos.generate_Header_labels('Usuarios') self.update_tb() self.ui.Btn_Guardar.clicked.connect(self.save) self.ui.Btn_Eliminar.clicked.connect(self.delete) self.ui.Btn_Editar.clicked.connect(self.edit) self.ui.Btn_Actualizar.setEnabled(False) self.ui.Btn_Actualizar.clicked.connect(lambda: self.save(True)) self.ui.Btn_Buscar.clicked.connect(lambda: self.update_tb(self.ui.Le_Buscar.text())) only_text = QRegExpValidator(QRegExp('^[A-Za-z]{3,20}')) self.ui.Le_Nombre.setValidator(only_text) self.ui.Le_Apellidos.setValidator(only_text) self.ui.Le_Rol.setValidator(only_text) email = QRegExpValidator(QRegExp("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")) self.ui.Le_Email.setValidator(email) only_numbers = QRegExpValidator(QRegExp('^[0-9]{3,10}')) self.ui.Le_Sueldo.setValidator(only_numbers) for le in self.data: le.textChanged.connect(self.check_changes) le.textChanged.emit(le.text())
def update_rules(self): self.rules = [] self.rules += [(r'\b%s\b' % w, 0, self.styles['keyword']) for w in keywords] self.rules += [(r'%s' % o, 0, self.styles['operator']) for o in operators] self.rules += [(r'%s' % b, 0, self.styles['brace']) for b in braces] self.rules += [ (r'\bself\b', 0, self.styles['self']), (r'"[^"\\]*(\\.[^"\\]*)*"', 0, self.styles['string']), (r"'[^'\\]*(\\.[^'\\]*)*'", 0, self.styles['string']), (r'\bdef\b\s*(\w+)', 1, self.styles['defclass']), # 'class' followed by an identifier (r'\bclass\b\s*(\w+)', 1, self.styles['defclass']), (r'#[^\n]*', 0, self.styles['comment']), (r'\b[+-]?[0-9]+[lL]?\b', 0, self.styles['numbers']), (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 0, self.styles['numbers']), (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0, self.styles['numbers']), ] self.rules = [(QRegularExpression(pat), index, fmt) for (pat, index, fmt) in self.rules] self.tri_single = (QRegExp("'''"), 1, self.styles['string2']) self.tri_double = (QRegExp('"""'), 2, self.styles['string2'])
def __init__(self, parent=None) -> None: super(AddContractor, self).__init__(parent) self.ui = Ui_AddContractor() self.ui.setupUi(self) self.setWindowFlags(Qt.Widget) self.ui.label_logo.setPixmap( QPixmap(ctx.resource("add_contractor.png"))) self.ui.input_zip_1.setValidator(QIntValidator(0, 99)) self.ui.input_zip_2.setValidator(QIntValidator(0, 999)) self.ui.input_zip_1.textEdited.connect(self.skip_zip_1) self.ui.input_zip_2.textEdited.connect(self.skip_zip_2) self.ui.input_nip.setValidator(QRegExpValidator(QRegExp("[0-9]*"))) self.ui.input_nip.textEdited.connect(self.validate_nip) self.ui.input_regon.setValidator(QRegExpValidator(QRegExp("[0-9]*"))) self.ui.input_regon.textEdited.connect(self.validate_regon) self.valid_pixmap = QPixmap(ctx.resource("valid.png")) self.invalid_pixmap = QPixmap(ctx.resource("invalid.png")) self.ui.button_add.clicked.connect(self.add_contractor) self.ui.button_cancel.clicked.connect(self.ask_close)
def rebuildRules(self): self._rules = [(QRegExp(pat), index, fmt) for (pat, index, fmt) in self._default_rules] if self._var_rules_map: self._rules += [(QRegExp(pat), index, fmt) for (pat, index, fmt) in self._var_rules_map.values()] self._rules += [(QRegExp(pat), index, fmt) for (pat, index, fmt) in self._comment_rules] self.rehighlight()
def __init__(self, parent=None): super(Highlighter, self).__init__(parent) keywordFormat = QTextCharFormat() keywordFormat.setForeground(QColor("#00CCFF")) keywordFormat.setFontCapitalization(QFont.AllUppercase) keywordPatterns = ["\\bSELECT\\b", "\\bFROM\\b", "\\bWHERE\\b", "\\bselect\\b", "\\bfrom\\b", "\\bwhere\\b", "\\bTABLE\\b", "\\btable\\b", "\\bON\\b", "\\bon\\b", "\\bORDER\\b", "\\border\\b", "\\bBY\\b", "\\bby\\b", "\\bLIMIT\\b", "\\blimit\\b", "\\bBETWEEN\\b", "\\bbetween\\b", "\\bLIKE\\b", "\\blike\\b", "\\bTO\\b", "\\bto\\b", "\\bINNER\\b", "\\inner\\b", "\\bJOIN\\b", "\\bjoin\\b", "\\bAND\\b", "\\and\\b", "\\bOR\\b", "\\bor\\b", ] self.highlightingRules = [(QRegExp(pattern), keywordFormat) for pattern in keywordPatterns] keyword2Format = QTextCharFormat() keyword2Format.setForeground(QColor("#DE0000")) keyword2Format.setFontCapitalization(QFont.AllUppercase) keyword2Patterns = ["\\bCREATE\\b", "\\bcreate\\b", "\\bINSERT\\b", "\\binsert\\b", "\\bUPDATE\\b", "\\bupdate\\b", "\\bDELETE\\b","\\bdelete\\b", "\\bREPLACE\\b", "\\breplace\\b", "\\bDROP\\b", "\\bdrop\\b", "\\bRENAME\\b", "\\rename\\b", "\\bALTER\\b", "\\alter\\b", "\\bSET\\b", "\\bset\\b" ] self.highlightingRules.extend([(QRegExp(pattern), keyword2Format) for pattern in keyword2Patterns]) table_name_format = QTextCharFormat() table_name_format.setForeground(QColor("#00FF7F")) table_name_format.setFontWeight(QFont.Bold) table_name_patterns = ["\\b{tn}\\b".format(tn=table.name) for table in Tables] ex_tables = ["\\b{tn}\\b".format(tn=table.name) for table in ExclusiveDbTables] table_name_patterns.extend(ex_tables) self.highlightingRules.extend([(QRegExp(pattern), table_name_format) for pattern in table_name_patterns]) field_name_format = QTextCharFormat() field_name_format.setForeground(QColor("#00FF7F")) field_names = [] for table in Tables: field_names.extend(getFieldNames(table.name)) for table in ExclusiveDbTables: field_names.extend(getAllFieldNames(table.name, False)) field_name_patterns = ["\\b{fn}\\b".format(fn=field_name) for field_name in field_names] self.highlightingRules.extend([(QRegExp(pattern), field_name_format) for pattern in field_name_patterns])
def __init__(self, document, styles): """ :param document: :type document: the textEdit document :param styles: The style dict :type styles: dict """ QSyntaxHighlighter.__init__(self, document) colors = styles["colors"] syntax = styles["syntax"] self.tri_single = (QRegExp("'''"), 1, colors['string']) self.tri_double = (QRegExp('"""'), 2, colors['string']) rules = [ # 'self' (r'\bself\b', 0, colors['self']), # Double-quoted string, possibly containing escape sequences (r'"[^"\\]*(\\.[^"\\]*)*"', 0, colors['string']), # Single-quoted string, possibly containing escape sequences (r"'[^'\\]*(\\.[^'\\]*)*'", 0, colors['string']), # 'def' followed by an identifier (r'\bdef\b\s*(\w+)', 1, colors['methods']), # 'class' followed by an identifier (r'\bclass\b\s*(\w+)', 1, colors['defclass']), # From '#' until a newline (r'#[^\n]*', 0, colors['comment']), (r"\\b[A-Za-z0-9_]+(?=\\()", 0, colors['methods']), # Numeric literals (r'\b[+-]?[0-9]+[lL]?\b', 0, colors['numbers']), (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 0, colors['numbers']), (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0, colors['numbers']), ] # Keyword, operator, and brace rules rules += [(r'\b%s\b' % w, 0, colors['keyword']) for w in syntax["keywords"]] rules += [(r'\b%s\b' % w, 0, colors['preprocessor']) for w in syntax["preprocessors"]] rules += [(r'\b%s\b' % w, 0, colors['special']) for w in syntax["specials"]] rules += [(r'%s' % o, 0, colors['operator']) for o in syntax["operators"]] rules += [(r'%s' % b, 0, colors['brace']) for b in syntax["braces"]] # Build a QRegExp for each pattern self.rules = [(QRegExp(pat), index, fmt) for (pat, index, fmt) in rules]
def __init__(self, document): QSyntaxHighlighter.__init__(self, document) # Multi-line strings (expression, flag, style) # FIXME: The triple-quotes in these two lines will mess up the # syntax highlighting from this point onward self.tri_single = (QRegExp("'''"), 1, STYLES['string2']) self.tri_double = (QRegExp('"""'), 2, STYLES['string2']) rules = [ (r'.', 0, STYLES["text"]), ] # Keyword, operator, and brace rules rules += [(r'\b%s\b' % w, 0, STYLES['keyword']) for w in PythonHighlighter.keywords] rules += [(r'%s' % o, 0, STYLES['operator']) for o in PythonHighlighter.operators] rules += [(r'%s' % b, 0, STYLES['brace']) for b in PythonHighlighter.braces] # All other rules rules += [ # 'self' (r'\bself\b', 0, STYLES['self']), # Double-quoted string, possibly containing escape sequences (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']), # Single-quoted string, possibly containing escape sequences (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLES['string']), # 'def' followed by an identifier (r'\bdef\b\s*(\w+)', 1, STYLES['defclass']), # 'class' followed by an identifier (r'\bclass\b\s*(\w+)', 1, STYLES['defclass']), # From '#' until a newline (r'#[^\n]*', 0, STYLES['comment']), # Numeric literals (r'\b[+-]?[0-9]+[lL]?\b', 0, STYLES['numbers']), (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 0, STYLES['numbers']), (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0, STYLES['numbers']), ] # Build a QRegExp for each pattern self.rules = [(QRegExp(pat), index, fmt) for (pat, index, fmt) in rules]
def onSearchFieldChanged(self): """Set the regex for each model""" # Add ".*" to enable partial matching if self.searchRegexCheckBox.isChecked(): regex = QRegExp(".*" + self.searchLineEdit.text() + ".*", Qt.CaseInsensitive) else: regex = QRegExp(self.searchLineEdit.text(), Qt.CaseInsensitive) for model in (self.newProxyModel, self.ownedProxyModel, self.ignoredProxyModel): model.setFilterRegExp(regex, self.searchRegexCheckBox.isChecked())
def setup_ui(self): #some useful things self.all_spin_boxes = self.window.findChildren(QSpinBox, QRegExp('.*')) self.dice_spin_boxes = self.window.findChildren( QSpinBox, QRegExp('^d[0-9]{1,3}SpinBox$')) self.other_spin_boxes = [ s for s in self.all_spin_boxes if s not in self.dice_spin_boxes ] self.labels = self.window.findChildren(QLabel, QRegExp('[A-z]*Value')) self.radio_buttons = self.window.findChildren(QRadioButton, QRegExp('[A-z]*Button')) self.connect_items() global debug if debug: self.__run_mini_test()
def filter_model(self, text): self.show() self.model.setFilterRegExp(QRegExp(text, QtCore.Qt.CaseInsensitive)) if not self.currently_expanded: self.expand() if self.model.rowCount() == 0: self.hide()
def __init__(self, dokument): super(AsemblerSintaksa, self).__init__(dokument) self.rules = [] self.formater = Formater() self.rules += [(r'\b%s\b' % w, 0, self.formater.stilovi['keyword']) for w in AsemblerSintaksa.keywords] self.rules += [(r'%s' % r, 0, self.formater.stilovi['register']) for r in AsemblerSintaksa.registers] self.rules += [(r'#[^\n]*', 0, self.formater.stilovi['comment'])] self.rules += [(r'\$[0-9]+\b', 0, self.formater.stilovi['literals'])] self.rules += [(r'\$0b[0-1]+\b', 0, self.formater.stilovi['literals'])] self.rules += [(r'\$0x[0-9a-fA-F]+\b', 0, self.formater.stilovi['literals'])] self.rules += [(r'\$[a-zA-Z_0-9]+\b', 0, self.formater.stilovi['literals'])] self.rules += [(r"\$\'[^']*\'", 0, self.formater.stilovi['literals'])] self.rules += [(r'\.%s\b' % d, 0, self.formater.stilovi['declarations']) for d in AsemblerSintaksa.declarations] self.rules += [(r'^(?!#).*[a-zA-Z0-9\_\-]+\:\s*', 0, self.formater.stilovi['label'])] self.rules += [(r"\".*\"", 0, self.formater.stilovi['string'])] self.rules += [(r"\'.?\'", 0, self.formater.stilovi['string'])] self.rules = [(QRegExp(pat), index, fmt) for (pat, index, fmt) in self.rules]
def __init__(self, parent, mode='dir', line_edit: QLineEdit = None, tool_button: QToolButton = None, dialog_args=(), reject_invalid_path_edits=False): super(SetDirectoryPath, self).__init__(parent) self.line_edit, self.tool_button = line_edit, tool_button self.mode = mode self.path = None self.parent = parent if self.tool_button: self.dialog_args = dialog_args self.tool_button.pressed.connect(self.btn_open_dialog) if self.line_edit: self.reject_invalid_path_edits = reject_invalid_path_edits regex = QRegExp(r'[^<>?"|*´`ß]*') regex.setCaseSensitivity(Qt.CaseInsensitive) self.line_edit.setValidator(QRegExpValidator(regex)) self.line_edit.editingFinished.connect(self.path_text_changed)
def __init__(self, label, text=None, value_type=VALUETYPE.STRING, ipRegex=None, input_width=50, parent=None, callback=None, runner=None): QWidget.__init__(self, parent) self.parent = parent self.__label = label self.input_width = input_width self.__ipRegex = ipRegex if value_type != VALUETYPE.STRING: self.__text = str(text) if not self.__ipRegex: self.__ipRegex = QRegExp("^[1-9]\\d{,3}$") else: self.__text = text self.callback = callback self.__runner = runner self.gui_init()
def __init__(self, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) self.setLayout(QVBoxLayout()) tv1 = QTableView(self) tv2 = QTableView(self) model = QStandardItemModel(8, 4, self) proxy = SortFilterProxyModel(self) proxy.setSourceModel(model) tv1.setModel(model) tv2.setModel(proxy) self.layout().addWidget(tv1) self.layout().addWidget(tv2) for i in range(model.rowCount()): for j in range(model.columnCount()): item = QStandardItem() item.setData(random_word(), Qt.DisplayRole) model.setItem(i, j, item) flayout = QFormLayout() self.layout().addLayout(flayout) for i in range(model.columnCount()): le = QLineEdit(self) flayout.addRow("column: {}".format(i), le) le.textChanged.connect(lambda text, col=i: proxy.setFilterByColumn( QRegExp(text, Qt.CaseSensitive, QRegExp.FixedString), col))
def __init__(self, parent=None): super(HPasteCollectionWidget.__HPasteCollectionWidget, self).__init__(parent, metadataExposedKeys=('raw_url', 'nettype')) for x in xrange(1, 5): self.ui.mainView.horizontalHeader().hideSection(x) self.__nepane = None self.__netType = '' self.__nettypeFilter = QSortFilterProxyModel(self) self.__nettypeFilter.setFilterKeyColumn(4) self.__nettypeFilter.setFilterRegExp( QRegExp("*", Qt.CaseInsensitive, QRegExp.Wildcard)) self.appendFilter(self.__nettypeFilter) self.accepted.connect(self.doOnAccept) self.__insideAuthCallback = False #self.setProperty("houdiniStyle", True) ss = "QTableView{border : 0px solid; gridline-color: rgb(48,48,48)}" ss += "QHeaderView::section{border-style: none; border-bottom: 0px; border-right: 0px;}" self.setStyleSheet(ss) self.__savedNetworkViewPos = None
def setupTabs(self): """ Setup the various tabs in the AddressWidget. """ groups = ["ABC", "DEF", "GHI", "JKL", "MNO", "PQR", "STU", "VW", "XYZ"] for group in groups: proxyModel = QSortFilterProxyModel(self) proxyModel.setSourceModel(self.tableModel) proxyModel.setDynamicSortFilter(True) tableView = QTableView() tableView.setModel(proxyModel) tableView.setSortingEnabled(True) tableView.setSelectionBehavior(QAbstractItemView.SelectRows) tableView.horizontalHeader().setStretchLastSection(True) tableView.verticalHeader().hide() tableView.setEditTriggers(QAbstractItemView.NoEditTriggers) tableView.setSelectionMode(QAbstractItemView.SingleSelection) # This here be the magic: we use the group name (e.g. "ABC") to # build the regex for the QSortFilterProxyModel for the group's # tab. The regex will end up looking like "^[ABC].*", only # allowing this tab to display items where the name starts with # "A", "B", or "C". Notice that we set it to be case-insensitive. reFilter = "^[%s].*" % group proxyModel.setFilterRegExp(QRegExp(reFilter, Qt.CaseInsensitive)) proxyModel.setFilterKeyColumn(0) # Filter on the "name" column proxyModel.sort(0, Qt.AscendingOrder) # This prevents an application crash (see: http://www.qtcentre.org/threads/58874-QListView-SelectionModel-selectionChanged-Crash) viewselectionmodel = tableView.selectionModel() tableView.selectionModel().selectionChanged.connect( self.selectionChanged) self.addTab(tableView, group)
def loadTemplateFile(self, templateFilePath=None): if templateFilePath == "": return False self.templateFilePath = templateFilePath self.usetablemodel.metadataList = [] self.usefilterModel.displayed = [] self.currentTemplate = templateFilePath.split("/")[-1] self.ui.displayedFileLabel.setText(templateFilePath.split("/")[-1]) self.ui.hyperthoughtTemplateLineEdit.setText(templateFilePath) self.ui.otherDataFileLineEdit.setText("") infile = open(templateFilePath, "r") data = infile.readline() fileType = infile.readline() fileType = json.loads(fileType) self.fileType = fileType[0][-4:] editables = infile.readline() self.editableKeys = json.loads(editables) self.usetablemodel.editableKeys = self.editableKeys self.toggleButtons() self.templatedata = json.loads(data) self.usetablemodel.addTemplateList(self.templatedata) self.usefilterModel.setFilterRegExp(QRegExp()) infile.close() return True
class ResolutionComboBox(ComboBoxDelegate): resolution_values = [ '1080 1080', '1280 720', '1280 960', '1920 1080', '1920 1440', '2560 1920', '2880 1620', '3840 2160', '4096 2160' ] regex = QRegExp('^\d{1,4}\s{1}\d{1,4}$') regex.setCaseSensitivity(Qt.CaseInsensitive) validator = QRegExpValidator(regex) def create_editor(self, parent, option, index): editor = QComboBox(parent) editor.setEditable(True) editor.setValidator(self.validator) current_value = index.model().data(index, Qt.EditRole) current_index = 0 for idx, value in enumerate(self.resolution_values): if current_value == value: current_index = idx editor.addItem(value) editor.setCurrentIndex(current_index) if current_value not in self.resolution_values: editor.addItem(current_value) editor.setCurrentIndex(editor.count()) return editor
def highlightBlock(self, text): for pattern, format in self.highlightingRules: expression = 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) startIndex = 0 if self.previousBlockState() != 1: startIndex = self.commentStartExpression.indexIn(text) while startIndex >= 0: endIndex = self.commentEndExpression.indexIn(text, startIndex) if endIndex == -1: self.setCurrentBlockState(1) commentLength = len(text) - startIndex else: commentLength = endIndex - startIndex + self.commentEndExpression.matchedLength( ) self.setFormat(startIndex, commentLength, self.multiLineCommentFormat) startIndex = self.commentStartExpression.indexIn( text, startIndex + commentLength)
def __init__(self, opts): super(GetKeypoolOptionsDialog, self).__init__() self.ui = Ui_GetKeypoolOptionsDialog() self.ui.setupUi(self) self.setWindowTitle('Set getkeypool options') self.ui.start_spinbox.setValue(opts['start']) self.ui.end_spinbox.setValue(opts['end']) self.ui.internal_checkbox.setChecked(opts['internal']) self.ui.keypool_checkbox.setChecked(opts['keypool']) self.ui.account_spinbox.setValue(opts['account']) self.ui.path_lineedit.setValidator( QRegExpValidator(QRegExp("m(/[0-9]+['Hh]?)+"), None)) if opts['account_used']: self.ui.account_radio.setChecked(True) self.ui.path_radio.setChecked(False) self.ui.path_lineedit.setEnabled(False) self.ui.account_spinbox.setEnabled(True) self.ui.account_spinbox.setValue(opts['account']) else: self.ui.account_radio.setChecked(False) self.ui.path_radio.setChecked(True) self.ui.path_lineedit.setEnabled(True) self.ui.account_spinbox.setEnabled(False) self.ui.path_lineedit.setText(opts['path']) self.ui.sh_wpkh_radio.setChecked( opts['addrtype'] == AddressType.SH_WIT) self.ui.wpkh_radio.setChecked(opts['addrtype'] == AddressType.WIT) self.ui.pkh_radio.setChecked(opts['addrtype'] == AddressType.LEGACY) self.ui.account_radio.toggled.connect(self.toggle_account)
def __create_line_label(self, name: str, label: str, min_width: int = 200, reg_exp: str = None) -> Tuple[Dict, Dict]: """__create_line_label will create a line edit button and his label Arguments: name {str} -- Default value label {str} -- Label name min_width {int} -- Minium width (default: {200}) Returns: Tuple[Dict, Dict] -- Line Edit, Label """ line_edit = QLineEdit(name) line_edit.setMinimumWidth(min_width) if reg_exp is not None: rx = QRegExp(reg_exp) validator = QRegExpValidator(rx, self) line_edit.setValidator(validator) label = QLabel(label) label.setBuddy(line_edit) return line_edit, label
def createEditor(self, parent, option, index): editor = QLineEdit(parent) editor.setAlignment(Qt.AlignRight) # Editor only accepts integers, period, or nothing regex = QRegExp('[0-9]*(\.[0-9]+)?') editor.setValidator(QRegExpValidator(regex, self)) return editor
def __init__(self): super().__init__() self.setTitle("Entrée") self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) main_layout = QFormLayout(self) main_layout.setHorizontalSpacing(20) main_layout.setVerticalSpacing(14) self._name_text = QLineEdit() self._name_validator = QRegExpValidator( QRegExp("^[a-zA-Z0-9_-#éèêëàîï ]{5,30}$")) self._name_text.setValidator(self._name_validator) self._name_text.inputRejected.connect(self._analysisNameError) self._name_text.textChanged.connect(self._analysisNameChanged) main_layout.addRow("Nom de l'analyse :", self._name_text) self._filepath_text = QLineEdit() self._filepath_button = QPushButton(" Parcourir... ") filepath_layout = QHBoxLayout() filepath_layout.setSpacing(8) filepath_layout.addWidget(self._filepath_text) filepath_layout.addWidget(self._filepath_button) main_layout.addRow("Dossier d'images à analyser :", filepath_layout) self.setLayout(main_layout) # Button slots self._filepath_button.clicked.connect(self.filepathBrowse)
def setupUi(self, Dialog): if Dialog.objectName(): Dialog.setObjectName(u"Dialog") Dialog.resize(201, 80) Dialog.setMinimumSize(201, 80) Dialog.setMaximumSize(201, 80) Dialog.setModal(True) self.buttonBox = QDialogButtonBox(Dialog) self.buttonBox.setObjectName(u"buttonBox") self.buttonBox.setGeometry(QRect(10, 40, 181, 32)) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.label = QLabel(Dialog) self.label.setObjectName(u"label") self.label.setGeometry(QRect(10, 10, 61, 21)) self.plainTextEdit = FilteredPlainTextEdit(Dialog) self.plainTextEdit.setObjectName(u"plainTextEdit") self.plainTextEdit.setGeometry(QRect(80, 10, 111, 21)) self.plainTextEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.plainTextEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.plainTextEdit.setScrollPolicy(FilteredPlainTextEdit.NoScroll) self.plainTextEdit.setExitOnReturn(True) self.plainTextEdit.setMaxLength(16) self.plainTextEdit.setValidator( QRegExpValidator(QRegExp(r"[0-9A-Fa-fx\-]*"), self.plainTextEdit)) self.retranslateUi(Dialog) self.buttonBox.accepted.connect(Dialog.accept) self.buttonBox.rejected.connect(Dialog.reject) QMetaObject.connectSlotsByName(Dialog)
def appendVarColor(self, var_name, color): reg_ex = self.VAR_PATTERN_PREFIX + var_name + self.VAR_PATTERN_SUFFIX style = self.formatText(color, style="italic") self._var_rules_map[var_name] = (QRegExp(reg_ex), 0, style) self.rebuildRules()
def set_limit(limit, auto_btn, manual_btn, edit): edit.setValidator(QRegExpValidator(QRegExp("\\d{1,9}"))) if limit: manual_btn.setChecked(True) edit.setText(str(limit)) else: auto_btn.setChecked(True) auto_btn.click()
def highlightBlock(self, text): for pattern, n, format in self.rules: exp = QRegExp(pattern) index = exp.indexIn(text) while index >= 0: length = exp.matchedLength() self.setFormat(index, length, format) index = exp.indexIn(text, index + length)
def setupEnvironmentComboBox(self): # Only allow alphabetic chars, digits, _, spaces: rx = QRegExp("[A-Za-z0-9 _]+") validator = QRegExpValidator(rx, self.widget) self.environmentsComboBox.setValidator(validator) self.environmentsComboBox.currentTextChanged.connect( self.onEnvironmentsComboBoxSelectedTextChanged)
def databaseHighlighting(self, text): for pattern, format_v in self.highlightingRules: expression = QRegExp(pattern) index = expression.indexIn(text) while index >= 0: length = expression.matchedLength() self.setFormat(index, length, format_v) index = expression.indexIn(text, index + length)
def highlightBlock(self, text): for pattern, _format in self.highlighting_rules: expression = QRegExp(pattern) index = expression.indexIn(text) while index >= 0: length = expression.matchedLength() self.setFormat(index, length, _format) index = expression.indexIn(text, index + length)