def highlightBlock(self, text): for rule in self.rules: expression = QRegExp(rule['pattern']) index = expression.indexIn(text) while index >= 0: length = expression.matchedLength() self.setFormat(index, length, rule['format']) index = expression.indexIn(text, index + length) self.setCurrentBlockState(0)
def highlightBlock(self, text): for rule in self.rules: expression = QRegExp(rule["pattern"]) index = expression.indexIn(text) while index >= 0: length = expression.matchedLength() self.setFormat(index, length, rule["format"]) index = expression.indexIn(text, index + length) self.setCurrentBlockState(0)
def Mr_Proper(self): util = FLUtil() self.db_.dbAux().transaction() rx = QRegExp("^.*[\\d][\\d][\\d][\\d].[\\d][\\d].*[\\d][\\d]$") rx2 = QRegExp("^.*alteredtable[\\d][\\d][\\d][\\d].*$") qry = FLSqlQuery(None, self.db_.dbAux()) qry2 = FLSqlQuery(None, self.db_.dbAux()) steps = 0 item = "" rx3 = QRegExp("^.*\\d{6,9}$") listOldBks = rx3 in self.tables("") qry.exec_("select nombre from flfiles") util.createProgressDialog(util.tr("Borrando backups"), len(listOldBks) + qry.size() + 5) while qry.next(): item = qry.value(0) if item.find(rx) > -1 or item.find(rx2) > -1: util.setLabelText(util.tr("Borrando regisro %1").arg(item)) qry2.exec_("delete from flfiles where nombre = '%s'" % item) if item.find("alteredtable") > -1: if item.replace(".mtd", "") in self.tables(""): util.setLabelText( util.tr("Borrando tabla %1").arg(item)) qry2.exec_("drop table %s" % (item.replace(".mtd", ""))) steps = steps + 1 util.setProgress(steps) for item in listOldBks: if item in self.tables(""): util.setLabelText(util.tr("Borrando tabla %1").arg(item)) qry2.exec_("drop table %s" % item) steps = steps + 1 util.setProgress(steps) util.setLabelText(util.tr("Inicializando cachés")) steps = steps + 1 util.setProgress(steps) qry.exec_("delete from flmetadata") qry.exec_("delete from flvar") self.db_.manager().cleanupMetaData() self.db_.dbAux().commit() util.setLabelText(util.tr("Vacunando base de datos")) steps = steps + 1 util.setProgress(steps) qry2.exec_("vacuum") steps = steps + 1 util.setProgress(steps) util.destryProgressDialog()
def __init__(self, parent=None): super(TemplateHighlighter, self).__init__(parent) self.initializeFormats() TemplateHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % keyword for keyword in self.KEYWORDS])), "keyword")) TemplateHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % builtin for builtin in formatter_functions().get_builtins()])), "builtin")) TemplateHighlighter.Rules.append((QRegExp( r"\b[+-]?[0-9]+[lL]?\b" r"|\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b" r"|\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b"), "number")) stringRe = QRegExp(r"""(?:[^:]'[^']*'|"[^"]*")""") stringRe.setMinimal(True) TemplateHighlighter.Rules.append((stringRe, "string")) lparenRe = QRegExp(r'\(') lparenRe.setMinimal(True) TemplateHighlighter.Rules.append((lparenRe, "lparen")) rparenRe = QRegExp(r'\)') rparenRe.setMinimal(True) TemplateHighlighter.Rules.append((rparenRe, "rparen")) self.regenerate_paren_positions() self.highlighted_paren = False
def match(self, text): """ Check if label matches search criterion. Arguments: text (str): Regular expression. Returns: bool: *True* if label matches search criterion; *False* otherwise. """ regex = QRegExp(text, Qt.CaseInsensitive) return regex.indexIn(self._titlelabel.text()) != -1 or \ regex.indexIn(self.path().name()) != -1
def get_text_widget(self, regexp): """ Return text QWidget with QTextEdit :return: text QWidget :rtype: QWidget """ text_widget = QWidget() text_widget.setObjectName('dialog') text_layout = QVBoxLayout() text_widget.setLayout(text_layout) text_layout.addWidget(self.valid_text) qreg_exp = QRegExp(regexp) self.validator.setRegExp(qreg_exp) self.line_edit.setPlaceholderText(_('type your text...')) self.line_edit.setText(self.old_text) self.line_edit.setValidator(self.validator) self.line_edit.setFixedHeight(25) self.line_edit.textChanged.connect(self.check_text) text_layout.addWidget(self.line_edit) # Accept button accept_btn = QPushButton(_('Confirm'), self) accept_btn.clicked.connect(self.accept_text) accept_btn.setObjectName('valid') accept_btn.setMinimumHeight(30) text_layout.addWidget(accept_btn) return text_widget
def __init__(self, *__args, _default_text: str = '0'): super(DisplayId, self).__init__(*__args) # Guarantee of getting an int-shaped string self.setValidator(QRegExpValidator(QRegExp(r'\d{8}'))) self.__default_text = _default_text self.setDefaultText(self.__default_text)
def initGui(self): self.main_layout = QHBoxLayout() send_input, send_btn, file_dialog, file_select, refresh_btn, recv_btn, ntwk_details = self.send_recv_gui( ) ipv4_input, port_input, conn_btn, disconn_btn, conn_label, conn_details = self.connect_to_addr_gui( ) # Set Input Validators port_reg = QRegExp("\d{5}") port_vali = QRegExpValidator(port_reg, port_input) port_input.setValidator(port_vali) # Add Button Functions conn_btn.released.connect(lambda: self.connect(ipv4_input.text( ), port_input.text(), conn_details, conn_label)) disconn_btn.released.connect( lambda: self.c.disconnect(conn_label, conn_details)) file_dialog.released.connect(lambda: self.browse(send_input)) refresh_btn.released.connect( lambda: self.c.request_file_names(file_select)) recv_btn.released.connect( lambda: self.c.my_receive(file_select.currentText(), ntwk_details)) send_btn.released.connect( lambda: self.c.my_send(send_input.text(), ntwk_details)) self.setLayout(self.main_layout)
def __init__(self, parent=None): super(QWidget, self).__init__(parent) self.le_input = QLineEdit(self) reg_ex = QRegExp("[1-9]+.?[0-9]{,2}") input_validator = QRegExpValidator(reg_ex, self.le_input) self.le_input.setValidator(input_validator)
def __init__(self): QtWidgets.QDialog.__init__(self) float_ex = QRegExp("[0-9]+[.]?[0-9]{1,2}") float_validator = QRegExpValidator(float_ex) int_pos_ex = QRegExp("[0-9]+") int_pos_validator = QRegExpValidator(int_pos_ex) self.ui = uic.loadUi('simulator_ui.ui') self.ui.startSimulation.clicked.connect(self.start_simulation) self.ui.stopSimulation.clicked.connect(self.stop_simulation) self.ui.exitProgramm.clicked.connect(self.exit_application) self.ui.bodyCount.setValidator(int_pos_validator) self.ui.minMass.setValidator(int_pos_validator) self.ui.minMassPot.setValidator(int_pos_validator) self.ui.maxMass.setValidator(int_pos_validator) self.ui.maxMassPot.setValidator(int_pos_validator) self.ui.minRad.setValidator(int_pos_validator) self.ui.minRadPot.setValidator(int_pos_validator) self.ui.maxRad.setValidator(int_pos_validator) self.ui.maxRadPot.setValidator(int_pos_validator) self.ui.centerMass.setValidator(int_pos_validator) self.ui.centerMassPot.setValidator(int_pos_validator) self.ui.centerRad.setValidator(int_pos_validator) self.ui.centerRadPot.setValidator(int_pos_validator) self.ui.scale.setValidator(int_pos_validator) self.ui.scalePot.setValidator(int_pos_validator) self.ui.slider.valueChanged.connect(self.update_slider_label) self.ui.stepScale.editingFinished.connect(self.update_slider) self.ui.stepScale.setValidator(int_pos_validator) self.ui.slider_label.editingFinished.connect(self.slider_label_changed) self.ui.slider_label.setValidator(float_validator) self.renderer_conn, self.simulation_conn = None, None self.render_process = None self.simulation_process = None multiprocessing.set_start_method('spawn') self.manager = Manager() self.step_scale = self.manager.Value('int', 0) self.update_slider_label()
def __init__(self, *args): QLineEdit.__init__(self, *args) self.setValidator(QRegExpValidator(QRegExp(r'\d+\.\d+'), self)) self.setToolTip(textwrap.fill('<p>'+_( 'Go to a reference. To get reference numbers, use the <i>reference ' 'mode</i>, by clicking the reference mode button in the toolbar.'))) if hasattr(self, 'setPlaceholderText'): self.setPlaceholderText(_('Go to...')) self.editingFinished.connect(self.editing_finished)
def filterItem(self, text): """ Filter out the item. Arguments: text (str): Regular expression. """ regex = QRegExp(text, Qt.CaseInsensitive) for i in range(self._list.topLevelItemCount()): item = self._list.topLevelItem(i) cnt_visible = 0 for j in xrange(item.childCount()): sub_item = item.child(j) item_text = sub_item.text(0) hidden = text != "" and regex.indexIn(item_text) == -1 sub_item.setHidden(hidden) if not hidden: cnt_visible += 1 item.setHidden(cnt_visible == 0)
def __init__(self, parent=None): super(PythonHighlighter, self).__init__(parent) self.initializeFormats() PythonHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % keyword for keyword in self.KEYWORDS])), "keyword")) PythonHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % builtin for builtin in self.BUILTINS])), "builtin")) PythonHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % constant for constant in self.CONSTANTS])), "constant")) PythonHighlighter.Rules.append((QRegExp( r"\b[+-]?[0-9]+[lL]?\b" r"|\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b" r"|\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b"), "number")) PythonHighlighter.Rules.append((QRegExp( r"\bPyQt5\b|\bQt?[A-Z][a-z]\w+\b"), "pyqt")) PythonHighlighter.Rules.append((QRegExp(r"\b@\w+\b"), "decorator")) stringRe = QRegExp(r"""(?:'[^']*'|"[^"]*")""") stringRe.setMinimal(True) PythonHighlighter.Rules.append((stringRe, "string")) self.stringRe = QRegExp(r"""(:?"["]".*"["]"|'''.*''')""") self.stringRe.setMinimal(True) PythonHighlighter.Rules.append((self.stringRe, "string")) self.tripleSingleRe = QRegExp(r"""'''(?!")""") self.tripleDoubleRe = QRegExp(r'''"""(?!')''')
def set_rules(self, item): self.rules = [] for each in self.items: if each.id == item.id: format_ = self.item_keywords else: format_ = self.keywords for w in map(_, each.keys()): pattern = QRegExp(r"\{%s.%s\}" % (_(each.name), w)) self.rules.append({'pattern': pattern, 'format': format_}) self.rehighlight()
def set_rules(self, item): self.rules = [] bad_syntax_format = QTextCharFormat() self.item_keywords.setFontWeight(QFont.Bold) bad_syntax_format.setForeground( QBrush(QColor(250, 0, 0), Qt.SolidPattern)) self.rules.append({ 'pattern': QRegExp(r'\{|\}'), 'format': bad_syntax_format, }) for each in self.items: if each.id == item.id: format_ = self.item_keywords else: format_ = self.keywords for w in map(_, each.keys()): pattern = QRegExp(r"\{%s.%s\}" % (_(each.name), w)) self.rules.append({'pattern': pattern, 'format': format_}) self.rehighlight()
def __init__(self): super().__init__() self.layout = QHBoxLayout() q_reg = QRegExp("\d{3}") for x in range(4): line_edit = QLineEdit() q_validator = QRegExpValidator(q_reg, line_edit) line_edit.setValidator(q_validator) line_edit.setFont(QFont(None, 13)) line_edit.setMaximumWidth(34) line_edit.setMinimumWidth(34) self.layout.addWidget(line_edit) if x < 3: self.layout.addWidget(QLabel(".")) self.line_edits.append(line_edit) self.layout.addStretch() self.setLayout(self.layout)
def request_octo_init_settings(self, wizard, method): vbox = QVBoxLayout() next_enabled = True label = QLabel(_("Enter a label to name your device:")) name = QLineEdit() hl = QHBoxLayout() hl.addWidget(label) hl.addWidget(name) hl.addStretch(1) vbox.addLayout(hl) def clean_text(widget): text = widget.toPlainText().strip() return ' '.join(text.split()) if method in [TIM_NEW, TIM_RECOVER]: gb = QGroupBox() hbox1 = QHBoxLayout() gb.setLayout(hbox1) vbox.addWidget(gb) gb.setTitle(_("Select your seed length:")) bg_numwords = QButtonGroup() for i, count in enumerate([12, 18, 24]): rb = QRadioButton(gb) rb.setText(_("%d words") % count) bg_numwords.addButton(rb) bg_numwords.setId(rb, i) hbox1.addWidget(rb) rb.setChecked(True) cb_pin = QCheckBox(_('Enable PIN protection')) cb_pin.setChecked(True) else: text = QTextEdit() text.setMaximumHeight(60) if method == TIM_MNEMONIC: msg = _("Enter your BIP39 mnemonic:") else: msg = _("Enter the master private key beginning with xprv:") def set_enabled(): from electrum.keystore import is_xprv wizard.next_button.setEnabled(is_xprv(clean_text(text))) text.textChanged.connect(set_enabled) next_enabled = False vbox.addWidget(QLabel(msg)) vbox.addWidget(text) pin = QLineEdit() pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,9}'))) pin.setMaximumWidth(100) hbox_pin = QHBoxLayout() hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):"))) hbox_pin.addWidget(pin) hbox_pin.addStretch(1) if method in [TIM_NEW, TIM_RECOVER]: vbox.addWidget(WWLabel(RECOMMEND_PIN)) vbox.addWidget(cb_pin) else: vbox.addLayout(hbox_pin) passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT) passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN) passphrase_warning.setStyleSheet("color: red") cb_phrase = QCheckBox(_('Enable passphrases')) cb_phrase.setChecked(False) vbox.addWidget(passphrase_msg) vbox.addWidget(passphrase_warning) vbox.addWidget(cb_phrase) # ask for recovery type (random word order OR matrix) if method == TIM_RECOVER: gb_rectype = QGroupBox() hbox_rectype = QHBoxLayout() gb_rectype.setLayout(hbox_rectype) vbox.addWidget(gb_rectype) gb_rectype.setTitle(_("Select recovery type:")) bg_rectype = QButtonGroup() rb1 = QRadioButton(gb_rectype) rb1.setText(_('Scrambled words')) bg_rectype.addButton(rb1) bg_rectype.setId(rb1, RECOVERY_TYPE_SCRAMBLED_WORDS) hbox_rectype.addWidget(rb1) rb1.setChecked(True) rb2 = QRadioButton(gb_rectype) rb2.setText(_('Matrix')) bg_rectype.addButton(rb2) bg_rectype.setId(rb2, RECOVERY_TYPE_MATRIX) hbox_rectype.addWidget(rb2) else: bg_rectype = None wizard.exec_layout(vbox, next_enabled=next_enabled) if method in [TIM_NEW, TIM_RECOVER]: item = bg_numwords.checkedId() pin = cb_pin.isChecked() recovery_type = bg_rectype.checkedId() if bg_rectype else None else: item = ' '.join(str(clean_text(text)).split()) pin = str(pin.text()) recovery_type = None return (item, name.text(), pin, cb_phrase.isChecked(), recovery_type)
def Mr_Proper(self): self.logger.warning("FLSQLITE: FIXME: Mr_Proper no regenera tablas") util = FLUtil() self.db_.dbAux().transaction() rx = QRegExp("^.*[\\d][\\d][\\d][\\d].[\\d][\\d].*[\\d][\\d]$") rx2 = QRegExp("^.*alteredtable[\\d][\\d][\\d][\\d].*$") qry = FLSqlQuery(None, "dbAux") qry2 = FLSqlQuery(None, "dbAux") qry3 = FLSqlQuery(None, "dbAux") steps = 0 item = "" rx3 = QRegExp("^.*\\d{6,9}$") #listOldBks = self.tables("").grep(rx3) listOldBks_prev = self.tables("") listOldBks = [] for l in listOldBks_prev: if rx3.indexIn(l) > -1: listOldBks.append(l) qry.exec_("select nombre from flfiles") util.createProgressDialog(util.tr("Borrando backups"), len(listOldBks) + qry.size() + 5) while qry.next(): item = qry.value(0) if rx.indexIn(item) > -1 or rx2.indexIn(item) > -1: util.setLabelText(util.tr("Borrando regisro %s" % item)) qry2.exec_("delete from flfiles where nombre = '%s'" % item) if item.find("alteredtable") > -1: if item.replace(".mtd", "") in self.tables(""): util.setLabelText(util.tr("Borrando tabla %s" % item)) qry2.exec_("drop table %s" % item.replace(".mtd", "")) steps = steps + 1 util.setProgress(steps) for item in listOldBks: if item in self.tables(""): util.tr("Borrando tabla %s" % item) util.setLabelText(util.tr("Borrando tabla %s" % item)) qry2.exec_("drop table %s" % item) steps = steps + 1 util.setProgress(steps) util.setLabelText(util.tr("Inicializando cachés")) steps = steps + 1 util.setProgress(steps) qry.exec_("delete from flmetadata") qry.exec_("delete from flvar") self.db_.manager().cleanupMetaData() self.db_.dbAux().commit() util.setLabelText(util.tr("Vacunando base de datos")) steps = steps + 1 util.setProgress(steps) qry3.exec_("vacuum") steps = steps + 1 util.setProgress(steps) util.destroyProgressDialog()
class PythonHighlighter(QSyntaxHighlighter): # {{{ Rules = [] Formats = {} KEYWORDS = [ "and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "exec", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "not", "or", "pass", "print", "raise", "return", "try", "while", "with", "yield" ] BUILTINS = [ "abs", "all", "any", "basestring", "bool", "callable", "chr", "classmethod", "cmp", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "execfile", "exit", "file", "filter", "float", "frozenset", "getattr", "globals", "hasattr", "hex", "id", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "long", "map", "max", "min", "object", "oct", "open", "ord", "pow", "property", "range", "reduce", "repr", "reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "unichr", "unicode", "vars", "xrange", "zip" ] CONSTANTS = ["False", "True", "None", "NotImplemented", "Ellipsis"] def __init__(self, parent=None): super(PythonHighlighter, self).__init__(parent) self.initializeFormats() PythonHighlighter.Rules.append((QRegExp("|".join( [r"\b%s\b" % keyword for keyword in self.KEYWORDS])), "keyword")) PythonHighlighter.Rules.append((QRegExp("|".join( [r"\b%s\b" % builtin for builtin in self.BUILTINS])), "builtin")) PythonHighlighter.Rules.append((QRegExp("|".join([ r"\b%s\b" % constant for constant in self.CONSTANTS ])), "constant")) PythonHighlighter.Rules.append( (QRegExp(r"\b[+-]?[0-9]+[lL]?\b" r"|\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b" r"|\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b"), "number")) PythonHighlighter.Rules.append( (QRegExp(r"\bPyQt5\b|\bQt?[A-Z][a-z]\w+\b"), "pyqt")) PythonHighlighter.Rules.append((QRegExp(r"\b@\w+\b"), "decorator")) stringRe = QRegExp(r"""(?:'[^']*'|"[^"]*")""") stringRe.setMinimal(True) PythonHighlighter.Rules.append((stringRe, "string")) self.stringRe = QRegExp(r"""(:?"["]".*"["]"|'''.*''')""") self.stringRe.setMinimal(True) PythonHighlighter.Rules.append((self.stringRe, "string")) self.tripleSingleRe = QRegExp(r"""'''(?!")""") self.tripleDoubleRe = QRegExp(r'''"""(?!')''') @classmethod def initializeFormats(cls): baseFormat = QTextCharFormat() baseFormat.setFontFamily('monospace') p = QApplication.instance().palette() for name, color, bold, italic in (("normal", None, False, False), ("keyword", p.color(p.Link).name(), True, False), ("builtin", p.color(p.Link).name(), False, False), ("constant", p.color(p.Link).name(), False, False), ("decorator", "#0000E0", False, False), ("comment", "#007F00", False, True), ("string", "#808000", False, False), ("number", "#924900", False, False), ("error", "#FF0000", False, False), ("pyqt", "#50621A", False, False)): fmt = QTextCharFormat(baseFormat) if color is not None: fmt.setForeground(QColor(color)) if bold: fmt.setFontWeight(QFont.Bold) if italic: fmt.setFontItalic(italic) cls.Formats[name] = fmt def highlightBlock(self, text): NORMAL, TRIPLESINGLE, TRIPLEDOUBLE, ERROR = range(4) textLength = len(text) prevState = self.previousBlockState() self.setFormat(0, textLength, PythonHighlighter.Formats["normal"]) if text.startswith("Traceback") or text.startswith("Error: "): self.setCurrentBlockState(ERROR) self.setFormat(0, textLength, PythonHighlighter.Formats["error"]) return if prevState == ERROR and \ not (text.startswith('>>>') or text.startswith("#")): self.setCurrentBlockState(ERROR) self.setFormat(0, textLength, PythonHighlighter.Formats["error"]) return for regex, format in PythonHighlighter.Rules: i = regex.indexIn(text) while i >= 0: length = regex.matchedLength() self.setFormat(i, length, PythonHighlighter.Formats[format]) i = regex.indexIn(text, i + length) # Slow but good quality highlighting for comments. For more # speed, comment this out and add the following to __init__: # PythonHighlighter.Rules.append((QRegExp(r"#.*"), "comment")) if not text: pass elif text[0] == "#": self.setFormat(0, len(text), PythonHighlighter.Formats["comment"]) else: stack = [] for i, c in enumerate(text): if c in ('"', "'"): if stack and stack[-1] == c: stack.pop() else: stack.append(c) elif c == "#" and len(stack) == 0: self.setFormat(i, len(text), PythonHighlighter.Formats["comment"]) break self.setCurrentBlockState(NORMAL) if self.stringRe.indexIn(text) != -1: return # This is fooled by triple quotes inside single quoted strings for i, state in ((self.tripleSingleRe.indexIn(text), TRIPLESINGLE), (self.tripleDoubleRe.indexIn(text), TRIPLEDOUBLE)): if self.previousBlockState() == state: if i == -1: i = len(text) self.setCurrentBlockState(state) self.setFormat(0, i + 3, PythonHighlighter.Formats["string"]) elif i > -1: self.setCurrentBlockState(state) self.setFormat(i, len(text), PythonHighlighter.Formats["string"]) def rehighlight(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) QSyntaxHighlighter.rehighlight(self) QApplication.restoreOverrideCursor()
def __init__(self, parent=None): super(PythonHighlighter, self).__init__(parent) self.initializeFormats() PythonHighlighter.Rules.append((QRegExp("|".join( [r"\b%s\b" % keyword for keyword in self.KEYWORDS])), "keyword")) PythonHighlighter.Rules.append((QRegExp("|".join( [r"\b%s\b" % builtin for builtin in self.BUILTINS])), "builtin")) PythonHighlighter.Rules.append((QRegExp("|".join([ r"\b%s\b" % constant for constant in self.CONSTANTS ])), "constant")) PythonHighlighter.Rules.append( (QRegExp(r"\b[+-]?[0-9]+[lL]?\b" r"|\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b" r"|\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b"), "number")) PythonHighlighter.Rules.append( (QRegExp(r"\bPyQt5\b|\bQt?[A-Z][a-z]\w+\b"), "pyqt")) PythonHighlighter.Rules.append((QRegExp(r"\b@\w+\b"), "decorator")) stringRe = QRegExp(r"""(?:'[^']*'|"[^"]*")""") stringRe.setMinimal(True) PythonHighlighter.Rules.append((stringRe, "string")) self.stringRe = QRegExp(r"""(:?"["]".*"["]"|'''.*''')""") self.stringRe.setMinimal(True) PythonHighlighter.Rules.append((self.stringRe, "string")) self.tripleSingleRe = QRegExp(r"""'''(?!")""") self.tripleDoubleRe = QRegExp(r'''"""(?!')''')
def __init__(self): super(ExtendedModeWindow, self).__init__() self.grid_layout = QGridLayout() self.grid_layout.setObjectName("grid_layout") self.setWindowTitle("Calculator - Extended Mode") self.resize(*self._normal_size) self.setMinimumSize(*self._normal_size) self.setStyleSheet( u"QTextBrowser { border: 0px; font-size 25pt; }" u"QWidget { background-color: #333333; color: white } " u"QPushButton { color: black; font-size: 15pt; background-color: #f4f4f4 } " u"QLineEdit { border: 0px; border-bottom: 1px solid white ; font-size: 15pt; }" ) self.label_bio = QLabel() self.label_bio.setText('Малых Евгений Александрович') self.label_bio.setFont(QFont("Calibri", 25)) self.label_bio.setAlignment(Qt.AlignCenter) self.label_bio.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.grid_layout.addWidget(self.label_bio, 0, 0, 1, 5) self.label_id = QLabel() self.label_id.setText('MUIV ID:') self.label_id.setFont(QFont("Calibri", 15)) self.label_id.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.label_id.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.grid_layout.addWidget(self.label_id, 1, 0, 1, 1) self.display_id = QLineEdit() self.display_id.setText(str(self._default_id)) self.display_id.setFont(QFont("Calibri", 15)) self.display_id.setAlignment(Qt.AlignCenter) self.display_id.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.display_id.setValidator(QRegExpValidator(QRegExp(r'\d{8}'))) self.grid_layout.addWidget(self.display_id, 1, 1, 1, 1) self.display = Display() self.display.setFont(QFont("Calibri", 12)) self.display.setFocusPolicy(Qt.NoFocus) self.display.setReadOnly(True) self.display.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) self.calculate_display_rows() self.grid_layout.addWidget(self.display, 2, 0, 1, 5) self.button_normal_mode = self.create_button("≡", position=(3, 0)) self.button_calculate_display_memory = self.create_button("<>", position=(3, 1)) self.button_memory_change = QComboBox() self.button_memory_change.setFont(QFont("Calibri", 14)) self.button_memory_change.clear() self.button_memory_change.addItems(self._memory_cells.keys()) self.grid_layout.addWidget(self.button_memory_change, 3, 2) self.button_deletion = self.create_button("←", position=(3, 3)) self.button_clear = self.create_button("C", position=(3, 4)) self.button_sinh = self.create_button("sinh", position=(4, 0)) self.button_mod = self.create_button("mod", position=(4, 1)) self.button_y_x = self.create_button("ʸ√ₓ", position=(4, 2)) self.button_lg_10 = self.create_button("lg10", position=(4, 3)) self.button_clear_all = self.create_button("CE", position=(4, 4)) self.button_memory_clear = self.create_button("MC", position=(5, 0)) self.button_memory_read = self.create_button("MR", position=(5, 1)) self.button_memory_save = self.create_button("MS", position=(5, 2)) self.button_memory_plus = self.create_button("M+", position=(5, 3)) self.ext_button_memory_minus = self.create_button("M-", position=(5, 4)) self.button_7 = self.create_button("7", position=(6, 0)) self.button_8 = self.create_button("8", position=(6, 1)) self.button_9 = self.create_button("9", position=(6, 2)) self.button_division = self.create_button("/", position=(6, 3)) self.button_degree = self.create_button("x^y", position=(6, 4)) self.button_4 = self.create_button("4", position=(7, 0)) self.button_5 = self.create_button("5", position=(7, 1)) self.button_6 = self.create_button("6", position=(7, 2)) self.button_multiplication = self.create_button("*", position=(7, 3)) self.button_root = self.create_button("√", position=(7, 4)) self.button_1 = self.create_button("1", position=(8, 0)) self.button_2 = self.create_button("2", position=(8, 1)) self.button_3 = self.create_button("3", position=(8, 2)) self.button_minus = self.create_button("-", position=(8, 3)) self.button_negative = self.create_button("±", position=(8, 4)) self.button_0 = self.create_button("0", position=(9, 0, 1, 2)) self.button_point = self.create_button(".", position=(9, 2)) self.button_plus = self.create_button("+", position=(9, 3)) self.button_equal = self.create_button("=", position=(9, 4)) self.setLayout(self.grid_layout) self.calculate_memory()
def initUI(self): self.resize(1280, 700) conLayout = QVBoxLayout() self.table = QTableWidget() self.table.setRowCount(93) self.table.setColumnCount(24) header_labels = [] for i in range(6): s1 = '%d月实际-金额' % (i + 1) s2 = '%d月实际-吨耗' % (i + 1) header_labels.append(s1) header_labels.append(s2) s1 = '%d月分解-金额' % (i + 1) s2 = '%d月费解-吨耗' % (i + 1) header_labels.append(s1) header_labels.append(s2) self.table.setHorizontalHeaderLabels(header_labels) self.table.setVerticalHeaderLabels(self._cost_type) # for i in range(12): # self.table.setSpan(0, 2*i+1, 1, 2) # self.table.setSpan(2, 2*i+1, 1, 2) # self.table.setItem(0, 2*i+1, self.setItem('%d月实际' % (i+1))) # # self.table.setItem(1, 2*i+1, self.setItem('金额')) # self.table.setItem(1, 2*i+2, self.setItem('吨耗')) # # for i in range(len(self._cost_type)): # self.table.setItem(2+i, 0, self.setItem(self._cost_type[i])) # twheader = QTableWidget() # twheader.setRowCount(2) # twheader.setColumnCount(26) # twheader.horizontalHeader().setVisible(False) # twheader.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # twheader.setEditTriggers(QAbstractItemView.NoEditTriggers) # twheader.setFocusPolicy(Qt.NoFocus) # # conLayout.addWidget(twheader) self.table.itemChanged.connect(self.table_item_changed) # self.table.itemSelectionChanged.connect(self.table_item_changed) conLayout.addWidget(self.table) self.btn_layout = QHBoxLayout() self.save_button = QPushButton('记得随时保存') self.cal_button = QPushButton('计算') self.create_button = QPushButton('生成excel') self.btn_layout.addWidget(self.save_button) self.btn_layout.addWidget(self.cal_button) self.btn_layout.addWidget(self.create_button) conLayout.addLayout(self.btn_layout) self.setLayout(conLayout) for i in range(93): for j in range(24): # self.table.setItem(i, j, self.setItem('0.00')) edit = QLineEdit('0.00') # edit.textChanged.connect(self.text_changed) edit.focusOutEvent(self.text_changed) edit.setValidator(QRegExpValidator(QRegExp('^\d+(\.\d\d)?$'))) self.table.setCellWidget(i, j, edit) self.center()
def __init__(self, *args): QLineEdit.__init__(self, *args) self.setValidator( QRegExpValidator(QRegExp(r'(^\d*\.[\d]{1,2}$)|(^[1-9]\d*[\.]$)'), self))
def __init__(self): super().__init__() self.D = None self.candidateFrm = QFrame(self) self.candidateGrid = QGridLayout() self.candidateList = [] self.prefix = "[" self.suffix = "]" self.TEXTWIDTH = 18 self.clpb = QApplication.clipboard() self.options = [] self.setFont(QFont('microsoft Yahei', font_size)) self.setWindowTitle(conf['Text', 'windowtitle']) self.file_path = '' #self.maxLineWidthpx = QApplication.desktop().availableGeometry().width() // 2 #self.maxLineWidth = self.maxLineWidthpx // (font_size * 4 //3) # 1px = 0.75point self.maxLineWidth = conf['Intval', 'LineWidth'] # in char self.wheelLock = False self.ticker = 0 self.lockTimer = QTimer(self) self.lockTimer.setSingleShot(False) self.lockTimer.setInterval(800) self.lockTimer.timeout.connect(self.unlockwheel) self.RoomIDinput = QLineEdit(self) numbers = QRegExpValidator(QRegExp("[0-9]{0,13}$")) self.RoomIDinput.setValidator(numbers) self.userWarnLabel = QLabel(self) self.Xffix = QLineEdit(self) self.Xffix.setPlaceholderText("前缀~后缀") self.UsingDictFile = QLabel(self) self.UsingDictFile.setText("meanings:") self.Textarea = Alt_textArea(self) self.Textarea.textChanged.connect(self.highlightText) self.Textarea.PickDict.connect(self.setCandidates) self.Textarea.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) """ font = self.Textarea.document().defaultFont() # or another font if you change it fontMetrics = QtGui.QFontMetrics(font) # a QFontMetrics based on our font textSize = fontMetrics.size(0, "这是一个十八个字长的汉字构成的字符串") self.Textarea.setFixedWidth(textSize.width()) """ self.placeholder = QLabel(self) self.placeholder.setText(placeholderSpaces) self.placeholderL = QLabel(self) self.placeholderL.setText(placeholderSpaces[:12]) self.cookieText = QTextEdit(self) self.cookieText.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) self.MeaningList = QLabel(self) self.MeaningList.setTextInteractionFlags(Qt.TextSelectableByMouse) #self.LRTOut.setMaximumWidth(self.maxLineWidth) #self.LRTOut.setWordWrap(True) self.LHintFile = QLabel(self) self.LHintFile.setText(conf['Text', 'hintFile']) self.LFileName = QLabel(self) self.markBtn = QPushButton(conf['Text', 'Bmark'], self) self.coolDown = QProgressBar(self) self.browseBtn = QPushButton(conf['Text', 'Bbrowse'], self) self.browseBtn.clicked.connect(self.browse) self.sendBtn = QPushButton("发射!", self) self.sendBtn.clicked.connect(self.sendLine) self.genFileBtn = QPushButton(conf['Text', 'Bgenerate'], self) self.settingLock = Toggle(self, text_false="", text_true="") self.settingLock.clicked.connect(self.settingStatusCheck) self.alwaysOnTop = Toggle(self) self.alwaysOnTop.clicked.connect(self.windowRefresh) self.aboutBtn = QPushButton(conf['Text', 'Babout'], self) self.aboutBtn.clicked.connect(self.about) self.QuitBtn = QPushButton(conf['Text', 'Bquit'], self) self.QuitBtn.clicked.connect(self.close) self.Cwidget = QFrame(self) self.initUI() self.lockTimer.start() self.wflags = self.windowFlags() self.alwaysOnTopFlag = False self.reqHandler = DanmuHandler(0) #invalid
def Mr_Proper(self): util = FLUtil() self.db_.dbAux().transaction() qry = FLSqlQuery(None, self.db_.dbAux()) qry2 = FLSqlQuery(None, self.db_.dbAux()) steps = 0 rx = QRegExp("^.*\\d{6,9}$") listOldBks = rx in self.tables("") qry.exec_( "select nombre from flfiles where nombre similar to" "'%[[:digit:]][[:digit:]][[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]%:[[:digit:]][[:digit:]]%' or nombre similar to" "'%alteredtable[[:digit:]][[:digit:]][[:digit:]][[:digit:]]%' or (bloqueo='f' and nombre like '%.mtd')" ) util.createProgressDialog(util.tr("Borrando backups"), len(listOldBks) + qry.size() + 2) while qry.next(): item = qry.value(0) util.setLabelText(util.tr("Borrando registro %1").arg(item)) qry2.exec_("DELETE FROM flfiles WERE nombre ='%s'" % item) if item.find("alteredtable") > -1: if self.existsTable(item.replace(".mtd", "")): util.setLabelText(util.tr("Borrando tabla %1").arg(item)) qry2.exec_("DROP TABLE %s CASCADE" % item.replace(".mtd", "")) steps = steps + 1 util.setProgress(steps) for item in listOldBks: if self.existsTable(item): util.setLabelText(util.tr("Borrando tabla %1").arg(item)) qry2.exec_("DROP TABLE %s CASCADE" % item) steps = steps + 1 util.setProgress(steps) util.setLabelText(util.tr("Inicializando cachés")) steps = steps + 1 util.setProgress(steps) qry.exec_("DELETE FROM flmetadata") qry.exec_("DELETE FROM flvar") self.db_.manager().cleanupMetaData() self.db_.commit() util.destroyProgressDialog() steps = 0 qry.exec_("select tablename from pg_tables where schemaname='public'") util.createProgressDialog(util.tr("Comprobando base de datos"), qry.size()) while qry.next(): item = qry.value(0) util.setLabelText(util.tr("Comprobando tabla %1").arg(item)) mustAlter = self.mismatchedTable(item, item) if mustAlter: conte = self.db_.managerModules().content("%s.mtd" % item) if conte: msg = util.tr( "La estructura de los metadatos de la tabla '%1' y su " "estructura interna en la base de datos no coinciden. " "Intentando regenerarla.").arg(item) print(msg) self.alterTable2(conte, conte, None, True) steps = steps + 1 util.setProgress(steps) self.db_.dbAux().transaction() steps = 0 sqlCursor = FLSqlCursor(None, True, self.db_.dbAux()) sqlQuery = FLSqlQuery(None, self.db_.dbAux()) if sqlQuery.exec_( "select relname from pg_class where ( relkind = 'r' ) " "and ( relname !~ '^Inv' ) " "and ( relname !~ '^pg_' ) and ( relname !~ '^sql_' )"): util.setTotalSteps(sqlQuery.size()) while sqlQuery.next(): item = sqlQuery.value(0) steps = steps + 1 util.setProgress(steps) util.setLabelText(util.tr("Creando índices para %1").arg(item)) mtd = self.db_.manager().metadata(item) fL = mtd.fieldList() if not mtd or not fL: continue for it in fL: if not it or not it.type() == "pixmap": continue cur = FLSqlCursor(item, True, self.db_.dbAux()) cur.select("%s not like 'RK@%'" % it.name()) while cur.next(): v = cur.value(it.name()) if v is None: continue v = self.db_.manager().storeLargeValue(mtd, v) if v: buf = cur.primeUpdate() buf.setValue(it.name(), v) cur.update(False) sqlCursor.setName(item, True) self.db_.dbAux().commit() steps = 0 qry.exec_("select tablename from pg_tables where schemaname='public'") util.createProgressDialog(util.tr("Analizando base de datos"), qry.size()) while qry.next(): item = qry.value(0) util.setLabelText(util.tr("Analizando tabla %1").arg(item)) qry2.exec_("vacuum analyze %s" % item) steps = steps + 1 util.setProgress(steps) util.destroyProgressDialog()
def _init_ui(self): self.setWindowTitle(self.config.title) self.resize(*self.config.size) self.setMinimumSize(*self.config.min_size) self.setStyleSheet(self.config.style_sheet) self.grid = QGridLayout() _cols = len(self.config.student_id) // 2 + 2 self.id_label = QLabel() self.id_label.setText( f'{self.config.student_name} | {self.config.student_id}') self.id_label.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) self.id_label.setFont(QFont(self.config.font, self.config.font_size)) self.id_label.setAlignment(Qt.AlignCenter) self.grid.addWidget(self.id_label, 0, 0, 1, _cols) _start_iteration = Iteration.get(percent=0) self.display = Display() self.display.show_stage(_start_iteration) self.display.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.display.setFont(QFont(self.config.font, self.config.font_size)) self.display.setAlignment(Qt.AlignCenter) self.grid.addWidget(self.display, 1, 0, 5, _cols) self.info_display = InfoDisplay() self.info_display.show_info(_start_iteration) self.info_display.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) self.info_display.setFont( QFont(self.config.font, self.config.font_size)) self.info_display.setAlignment(Qt.AlignCenter) self.grid.addWidget(self.info_display, 6, 0, 1, _cols) _n = int() for col in range(_cols): if col == 0: self.button_start = QPushButton() self.button_start.setText('Draw begin') self.button_start.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.button_start.setFont( QFont(self.config.font, self.config.font_size)) self.grid.addWidget(self.button_start, 7, col, 2, 1) elif col == _cols - 1: self.button_end = QPushButton() self.button_end.setText('Draw end') self.button_end.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.button_end.setFont( QFont(self.config.font, self.config.font_size)) self.grid.addWidget(self.button_end, 7, col, 2, 1) else: entry = QLineEdit() entry.setValidator(QRegExpValidator(QRegExp(r'\d{2}'))) entry.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) entry.setFont(QFont(self.config.font, self.config.font_size)) entry.setAlignment(Qt.AlignCenter) entry.setText(self.config.student_id[_n * 2:_n * 2 + 2]) _n += 1 self.grid.addWidget(entry, 7, col, 1, 1) setattr(self, f'entry_{col}', entry) button = QPushButton() button.setText(f'Draw: {col}') button.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) button.setFont(QFont(self.config.font, self.config.font_size)) self.grid.addWidget(button, 8, col, 1, 1) setattr(self, f'button_{col}', button) self.setLayout(self.grid)
class PythonHighlighter(QSyntaxHighlighter): # {{{ Rules = [] Formats = {} KEYWORDS = ["and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "exec", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "not", "or", "pass", "print", "raise", "return", "try", "while", "with", "yield"] BUILTINS = ["abs", "all", "any", "basestring", "bool", "callable", "chr", "classmethod", "cmp", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "execfile", "exit", "file", "filter", "float", "frozenset", "getattr", "globals", "hasattr", "hex", "id", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "long", "map", "max", "min", "object", "oct", "open", "ord", "pow", "property", "range", "reduce", "repr", "reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "unichr", "unicode", "vars", "xrange", "zip"] CONSTANTS = ["False", "True", "None", "NotImplemented", "Ellipsis"] def __init__(self, parent=None): super(PythonHighlighter, self).__init__(parent) self.initializeFormats() PythonHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % keyword for keyword in self.KEYWORDS])), "keyword")) PythonHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % builtin for builtin in self.BUILTINS])), "builtin")) PythonHighlighter.Rules.append((QRegExp( "|".join([r"\b%s\b" % constant for constant in self.CONSTANTS])), "constant")) PythonHighlighter.Rules.append((QRegExp( r"\b[+-]?[0-9]+[lL]?\b" r"|\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b" r"|\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b"), "number")) PythonHighlighter.Rules.append((QRegExp( r"\bPyQt5\b|\bQt?[A-Z][a-z]\w+\b"), "pyqt")) PythonHighlighter.Rules.append((QRegExp(r"\b@\w+\b"), "decorator")) stringRe = QRegExp(r"""(?:'[^']*'|"[^"]*")""") stringRe.setMinimal(True) PythonHighlighter.Rules.append((stringRe, "string")) self.stringRe = QRegExp(r"""(:?"["]".*"["]"|'''.*''')""") self.stringRe.setMinimal(True) PythonHighlighter.Rules.append((self.stringRe, "string")) self.tripleSingleRe = QRegExp(r"""'''(?!")""") self.tripleDoubleRe = QRegExp(r'''"""(?!')''') @classmethod def initializeFormats(cls): if cls.Formats: return baseFormat = QTextCharFormat() baseFormat.setFontFamily('monospace') baseFormat.setFontPointSize(11) for name, color, bold, italic in ( ("normal", "#000000", False, False), ("keyword", "#000080", True, False), ("builtin", "#0000A0", False, False), ("constant", "#0000C0", False, False), ("decorator", "#0000E0", False, False), ("comment", "#007F00", False, True), ("string", "#808000", False, False), ("number", "#924900", False, False), ("error", "#FF0000", False, False), ("pyqt", "#50621A", False, False)): format = QTextCharFormat(baseFormat) format.setForeground(QColor(color)) if bold: format.setFontWeight(QFont.Bold) format.setFontItalic(italic) cls.Formats[name] = format def highlightBlock(self, text): NORMAL, TRIPLESINGLE, TRIPLEDOUBLE, ERROR = range(4) textLength = len(text) prevState = self.previousBlockState() self.setFormat(0, textLength, PythonHighlighter.Formats["normal"]) if text.startswith(u"Traceback") or text.startswith(u"Error: "): self.setCurrentBlockState(ERROR) self.setFormat(0, textLength, PythonHighlighter.Formats["error"]) return if prevState == ERROR and \ not (text.startswith(u'>>>') or text.startswith(u"#")): self.setCurrentBlockState(ERROR) self.setFormat(0, textLength, PythonHighlighter.Formats["error"]) return for regex, format in PythonHighlighter.Rules: i = regex.indexIn(text) while i >= 0: length = regex.matchedLength() self.setFormat(i, length, PythonHighlighter.Formats[format]) i = regex.indexIn(text, i + length) # Slow but good quality highlighting for comments. For more # speed, comment this out and add the following to __init__: # PythonHighlighter.Rules.append((QRegExp(r"#.*"), "comment")) if not text: pass elif text[0] == u"#": self.setFormat(0, len(text), PythonHighlighter.Formats["comment"]) else: stack = [] for i, c in enumerate(text): if c in (u'"', u"'"): if stack and stack[-1] == c: stack.pop() else: stack.append(c) elif c == u"#" and len(stack) == 0: self.setFormat(i, len(text), PythonHighlighter.Formats["comment"]) break self.setCurrentBlockState(NORMAL) if self.stringRe.indexIn(text) != -1: return # This is fooled by triple quotes inside single quoted strings for i, state in ((self.tripleSingleRe.indexIn(text), TRIPLESINGLE), (self.tripleDoubleRe.indexIn(text), TRIPLEDOUBLE)): if self.previousBlockState() == state: if i == -1: i = len(text) self.setCurrentBlockState(state) self.setFormat(0, i + 3, PythonHighlighter.Formats["string"]) elif i > -1: self.setCurrentBlockState(state) self.setFormat(i, len(text), PythonHighlighter.Formats["string"]) def rehighlight(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) QSyntaxHighlighter.rehighlight(self) QApplication.restoreOverrideCursor()
def __init__(self, astergui, parent=None): """ Create panel. Arguments: astergui (AsterGui): AsterGui instance. parent (Optional[QWidget]): Parent widget. """ super(ParameterPanel, self).__init__(parent=parent, name=translate("ParameterPanel", "Edit command"), astergui=astergui) self.setPixmap(load_pixmap("as_pic_edit_command.png")) self._files_model = astergui.study().dataFilesModel() self._unit_model = None self._command = None self.title = ParameterTitle(self) self.title.installEventFilter(self) self._name = QLineEdit(self) self.views = QStackedWidget(self) v_layout = QVBoxLayout(self) v_layout.setContentsMargins(0, 0, 0, 0) v_layout.setSpacing(5) v_layout.addWidget(self.title) v_layout.addWidget(HLine(self)) n_layout = QHBoxLayout() v_layout.addLayout(n_layout) n_layout.addWidget(QLabel(translate("ParameterPanel", "Name"), self)) n_layout.addWidget(self._name) # force to be a valid identifier + length <= 8 self._name.setValidator(QRegExpValidator(QRegExp(r"[a-zA-Z]\w{1,7}"))) # create toolbar tbar = QToolBar(self) tbar.setToolButtonStyle(Qt.ToolButtonIconOnly) # - Edit comment edit_comment = QAction(translate("AsterStudy", "Edit &Comment"), self) edit_comment.setToolTip(translate("AsterStudy", "Edit comment")) edit_comment.setStatusTip( translate("AsterStudy", "Edit comment for the " "selected object")) edit_comment.setIcon(load_icon("as_pic_edit_comment.png")) connect(edit_comment.triggered, self._editComment) tbar.addAction(edit_comment) # - Switch on/off business-translations title = translate("AsterStudy", "Use Business-Oriented Translations") self.use_translations = QAction(title, self) title = translate("AsterStudy", "Use business-oriented translations") self.use_translations.setToolTip(title) self.use_translations.setStatusTip(title) self.use_translations.setIcon(load_icon("as_pic_use_translations.png")) self.use_translations.setCheckable(True) if behavior().forced_native_names: force = behavior().force_native_names self.use_translations.setDisabled(True) is_on = not force else: is_on = behavior().use_business_translations Options.use_translations = is_on self.use_translations.setChecked(is_on) connect(self.use_translations.toggled, self.updateTranslations) tbar.addAction(self.use_translations) # - Hide unused hide_unused = astergui.action(ActionType.HideUnused) connect(hide_unused.toggled, self._unusedVisibility) tbar.addAction(hide_unused) # - What's this whats_this = QWhatsThis.createAction(tbar) whats_this.setToolTip(translate("AsterStudy", "What's this?")) whats_this.setStatusTip( translate("AsterStudy", "Show element's description")) whats_this.setIcon(load_icon("as_pic_whats_this.png")) tbar.addAction(whats_this) # - Link to doc tbar.addAction(astergui.action(ActionType.LinkToDoc)) n_layout.addWidget(tbar) v_layout.addWidget(self.views) self._updateState()