def __init__(self, parent): super(BruteForceView, self).__init__("bruteforce", parent) self.category = "bf" regex = QRegExp("\d{1,6}") self.__validator = QRegExpValidator(regex, self.lineEditPort) self.lineEditPort.setValidator(self.__validator) regex = QRegExp("\d{1,5}") self.__validator = QRegExpValidator(regex, self.lineEditPort) self.lineEditMaximum.setValidator(self.__validator) # Connect buttons self.pushButtonCancel.clicked.connect(self.pushButtonCancelClicked) self.pushButtonExploit.clicked.connect(self.pushButtonExploitClicked) self.toolButtonUsers.clicked.connect(self.toolButtonUsersClicked) self.toolButtonPasswords.clicked.connect( self.toolButtonPasswordsClicked) # Connect signal and thread self.__communicate = Communicate() self.__exploitThread = ExploitThread(self.__communicate) self.__communicate.finishExploit.connect(self.setResultExploit) # Button and progressbar self.setProgressBarState(0) self.pushButtonCancel.setEnabled(False) # Generator self.__generatorUsers = Generator() self.__generatorPasswords = Generator()
def __init__(self, parent=None): super(GithubCredentialsWizardPage, self).__init__(parent, title="Credentials", subTitle="Enter your username/password or token") # Radio Buttons self.userPassRadioButton = QRadioButton() self.userPassRadioButton.toggled.connect(self.changeMode) self.userPassRadioButton.toggled.connect(self.completeChanged.emit) self.tokenRadioButton = QRadioButton() self.tokenRadioButton.toggled.connect(self.changeMode) self.tokenRadioButton.toggled.connect(self.completeChanged.emit) # LineEdits # usernameEdit self.usernameEdit = QLineEdit(textChanged=self.completeChanged.emit) # Username may only contain alphanumeric characters or dash # and cannot begin with a dash self.usernameEdit.setValidator( QRegExpValidator(QRegExp('[A-Za-z\d]+[A-Za-z\d-]+'))) # passwordEdit self.passwordEdit = QLineEdit(textChanged=self.completeChanged.emit) self.passwordEdit.setValidator(QRegExpValidator(QRegExp('.+'))) self.passwordEdit.setEchoMode(QLineEdit.Password) # tokenEdit self.tokenEdit = QLineEdit(textChanged=self.completeChanged.emit) # token may only contain alphanumeric characters self.tokenEdit.setValidator(QRegExpValidator(QRegExp('[A-Za-z\d]+'))) self.tokenEdit.setEchoMode(QLineEdit.Password) # Form form = QFormLayout() form.addRow("<b>username/password</b>", self.userPassRadioButton) form.addRow("username: "******"password: "******"<b>token</b>", self.tokenRadioButton) form.addRow("token: ", self.tokenEdit) # Layout self.mainLayout = QVBoxLayout() self.mainLayout.addLayout(form) self.setLayout(self.mainLayout) # Fields self.registerField("username", self.usernameEdit) self.registerField("password", self.passwordEdit) self.registerField("token", self.tokenEdit) self.userPassRadioButton.toggle() self.require_2fa = False
def create_widgets(self): punctuationRe = QRegExp(r"[ ,;:.]") self.thousandsLabel = QLabel("&Thousands separator") self.thousandsEdit = QLineEdit(self.format["thousandsseparator"]) self.thousandsLabel.setBuddy(self.thousandsEdit) self.thousandsEdit.setMaxLength(1) self.thousandsEdit.setValidator(QRegExpValidator(punctuationRe, self)) self.decimalMarkerLabel = QLabel("Decimal &marker") self.decimalMarkerEdit = QLineEdit(self.format["decimalmarker"]) self.decimalMarkerLabel.setBuddy(self.decimalMarkerEdit) self.decimalMarkerEdit.setMaxLength(1) self.decimalMarkerEdit.setValidator( QRegExpValidator(punctuationRe, self)) self.decimalMarkerEdit.setInputMask("X") self.decimalPlacesLabel = QLabel("&Decimal places") self.decimalPlacesSpinBox = QSpinBox() self.decimalPlacesLabel.setBuddy(self.decimalPlacesSpinBox) self.decimalPlacesSpinBox.setRange(0, 6) self.decimalPlacesSpinBox.setValue(self.format["decimalplaces"]) self.redNegativesCheckBox = QCheckBox("&Red negative numbers") self.redNegativesCheckBox.setChecked(self.format["rednegatives"]) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Close)
def __setup_ui(self): self.setMaximumSize(300, 300) self.setMinimumSize(300, 300) vlayout = QVBoxLayout() host_layout = QHBoxLayout() port_layout = QHBoxLayout() slotid_layout = QHBoxLayout() intfid_layout = QHBoxLayout() onuid_layout = QHBoxLayout() btn_layout = QHBoxLayout() host_layout.addWidget(QLabel('Host'), 3) self.__host_edit = QLineEdit('192.168.184.128') #self.__host_edit = QLineEdit() self.__host_edit.setValidator(QRegExpValidator(self.__host_reg)) host_layout.addWidget(self.__host_edit, 7) port_layout.addWidget(QLabel('Port'), 3) self.__port_edit = QLineEdit('6641') #self.__port_edit = QLineEdit() self.__port_edit.setValidator(QRegExpValidator(self.__port_reg)) port_layout.addWidget(self.__port_edit, 7) slotid_layout.addWidget(QLabel('Slot id'), 3) # self.__port_edit = QLineEdit('6641') self.__slotid_edit = QLineEdit('1') self.__slotid_edit.setValidator(QRegExpValidator(QRegExp("[0-9]"))) slotid_layout.addWidget(self.__slotid_edit, 7) intfid_layout.addWidget(QLabel('Intf id'), 3) self.__intfid_edit = QLineEdit('0') self.__intfid_edit.setValidator(QRegExpValidator( QRegExp("[0-9][0-9]"))) intfid_layout.addWidget(self.__intfid_edit, 7) onuid_layout.addWidget(QLabel('Intf id'), 3) # self.__port_edit = QLineEdit('6641') self.__onuid_edit = QLineEdit('1') self.__onuid_edit.setValidator(QRegExpValidator(QRegExp("[0-9][0-9]"))) onuid_layout.addWidget(self.__onuid_edit, 7) self.ok_btn = QPushButton('ok') #self.ok_btn.setFlat(True) #self.ok_btn.setEnabled(False) self.cancel_btn = QPushButton('cancel') btn_layout.addWidget(self.ok_btn, 5) btn_layout.addWidget(self.cancel_btn, 5) vlayout.addLayout(host_layout) vlayout.addLayout(port_layout) vlayout.addLayout(slotid_layout) vlayout.addLayout(intfid_layout) vlayout.addLayout(onuid_layout) vlayout.addLayout(btn_layout) self.setLayout(vlayout)
def enable_fields(self, index): hours_reg = QRegExp(r"0*[0-9]{1,3}") sec_reg = QRegExp(r"(0*[0-9])|(0*[0-5][0-9])") for counter, line_edit in enumerate(self.lineEdits_list[index - 1]): line_edit.setEnabled(self.valve_list[index - 1].isChecked()) if counter % 3 == 0: line_edit.setValidator(QRegExpValidator(hours_reg, self)) else: line_edit.setValidator(QRegExpValidator(sec_reg, self))
def __init__(self, format, parent=None): super(NumberFormatDlg, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) punctuationRe = QRegExp(r"[ ,;:.]") thousandsLabel = QLabel("&Thousands separator") self.thousandsEdit = QLineEdit(format["thousandsseparator"]) thousandsLabel.setBuddy(self.thousandsEdit) self.thousandsEdit.setMaxLength(1) self.thousandsEdit.setValidator(QRegExpValidator(punctuationRe, self)) decimalMarkerLabel = QLabel("Decimal &marker") self.decimalMarkerEdit = QLineEdit(format["decimalmarker"]) decimalMarkerLabel.setBuddy(self.decimalMarkerEdit) self.decimalMarkerEdit.setMaxLength(1) self.decimalMarkerEdit.setValidator( QRegExpValidator(punctuationRe, self)) self.decimalMarkerEdit.setInputMask("X") decimalPlacesLabel = QLabel("&Decimal places") self.decimalPlacesSpinBox = QSpinBox() decimalPlacesLabel.setBuddy(self.decimalPlacesSpinBox) self.decimalPlacesSpinBox.setRange(0, 6) self.decimalPlacesSpinBox.setValue(format["decimalplaces"]) self.redNegativesCheckBox = QCheckBox("&Red negative numbers") self.redNegativesCheckBox.setChecked(format["rednegatives"]) buttonBox = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Close) self.format = format grid = QGridLayout() grid.addWidget(thousandsLabel, 0, 0) grid.addWidget(self.thousandsEdit, 0, 1) grid.addWidget(decimalMarkerLabel, 1, 0) grid.addWidget(self.decimalMarkerEdit, 1, 1) grid.addWidget(decimalPlacesLabel, 2, 0) grid.addWidget(self.decimalPlacesSpinBox, 2, 1) grid.addWidget(self.redNegativesCheckBox, 3, 0, 1, 2) grid.addWidget(buttonBox, 4, 0, 1, 2) self.setLayout(grid) self.connect(buttonBox.button(QDialogButtonBox.Apply), SIGNAL("clicked()"), self.apply) self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()")) self.setWindowTitle("Set Number Format (Modeless)")
def set_dialog_validators(self): """ Add validators to the free-text fields of the dialog. """ # These widgets are 'free-text' self.dlg.ui.usrnLineEdit.setValidator( QRegExpValidator(QRegExp(r"\d{0,8}"))) self.dlg.ui.ref1LineEdit.setValidator( QRegExpValidator(QRegExp(r"[ABCUFTMZ]{1,2}-?\d{0,}"))) self.dlg.ui.ref2LineEdit.setValidator( QRegExpValidator(QRegExp(r"\d{0,}"))) # There isn't length validation for plain text edit, so implement our own self.dlg.ui.sectionDescriptionPlainTextEdit.textChanged.connect( self.trim_section_description)
def createWidgets(self): numeric_reg = QRegExp(r"[0-9]+") self.line_width_label = QLabel('Line Width') self.line_width_edit = QLineEdit() self.line_width_edit.setValidator(QRegExpValidator(numeric_reg, self)) self.line_width_edit.setText(str(self.settings['plotLineWidth'])) self.horizontal_grid_label = QLabel('Horizontal Grid') self.horizontal_grid_checkbox = QCheckBox() self.horizontal_grid_checkbox.setChecked( self.settings['horizontalGrid']) self.vertical_grid_label = QLabel('Vertical Grid') self.vertical_grid_checkbox = QCheckBox() self.vertical_grid_checkbox.setChecked(self.settings['verticalGrid']) self.grid_opacity_label = QLabel('Line Opacity') self.grid_opacity_spinbox = QDoubleSpinBox() self.grid_opacity_spinbox.setRange(0.10, 1.00) self.grid_opacity_spinbox.setSingleStep(0.10) self.grid_opacity_spinbox.setValue(float(self.settings['gridOpacity'])) self.grid_opacity_spinbox.setFocusPolicy(Qt.NoFocus) self.line_color_label = QLabel('Line Color') self.line_color_combo = QComboBox() self.line_color_combo.addItem('blue') self.line_color_combo.addItem('cyan') self.line_color_combo.addItem('green') self.line_color_combo.addItem('magenta') self.line_color_combo.addItem('white') self.line_color_combo.addItem('yellow') print self.settings['lineColor'] self.line_color_combo.setCurrentIndex( self.line_color_combo.findText(self.settings['lineColor'])) self.serial_baud_label = QLabel('Serial Baud') self.serial_baud_edit = QLineEdit() self.serial_baud_edit.setText(str(self.settings['serialBaud'])) self.serial_baud_edit.setValidator(QRegExpValidator(numeric_reg, self)) self.separator_label = QLabel('Separator') self.separator_edit = QLineEdit() self.separator_edit.setText(self.settings['separator']) self.separator_edit.setInputMask('X') self.buttonBox = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Close | QDialogButtonBox.RestoreDefaults)
def __init__(self, parent=None, default_value=0): QSpinBox.__init__(self, parent) self.validator = QRegExpValidator(QRegExp("[0-9A-Fa-f]{1,2}"), self) self.setRange(0, 255) self.setValue(default_value)
def __init__(self, show_strength=True, parent=None): super(PinMatrixWidget, self).__init__(parent) self.password = QLineEdit() self.password.setValidator(QRegExpValidator(QRegExp('[1-9]+'), None)) self.password.setEchoMode(QLineEdit.Password) QObject.connect(self.password, SIGNAL('textChanged(QString)'), self._password_changed) self.strength = QLabel() self.strength.setMinimumWidth(75) self.strength.setAlignment(Qt.AlignCenter) self._set_strength(0) grid = QGridLayout() grid.setSpacing(0) for y in range(3)[::-1]: for x in range(3): button = PinButton(self.password, x + y * 3 + 1) button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) button.setFocusPolicy(Qt.NoFocus) grid.addWidget(button, 3 - y, x) hbox = QHBoxLayout() hbox.addWidget(self.password) if show_strength: hbox.addWidget(self.strength) vbox = QVBoxLayout() vbox.addLayout(grid) vbox.addLayout(hbox) self.setLayout(vbox)
def __init__(self, parent=None, iface=None): """Constructor for import dialog. .. versionadded: 3.3 :param parent: Optional widget to use as parent. :type parent: QWidget :param iface: An instance of QGisInterface. :type iface: QGisInterface """ QDialog.__init__(self, parent) self.parent = parent self.setupUi(self) title = self.tr('PetaBencana Downloader') self.setWindowTitle(title) icon = resources_path('img', 'icons', 'add-petabencana-layer.svg') self.setWindowIcon(QtGui.QIcon(icon)) self.iface = iface self.source = None self.radio_button_group = QButtonGroup() self.radio_button_group.addButton(self.radio_button_production) self.radio_button_group.addButton(self.radio_button_development) self.radio_button_group.setExclusive(True) self.radio_button_production.setChecked(True) self.populate_combo_box() developer_mode = setting('developer_mode', False, bool) if not developer_mode: self.radio_button_widget.hide() self.source_label.hide() self.output_group.adjustSize() # signals self.radio_button_production.clicked.connect(self.populate_combo_box) self.radio_button_development.clicked.connect(self.populate_combo_box) # creating progress dialog for download self.progress_dialog = QProgressDialog(self) self.progress_dialog.setAutoClose(False) self.progress_dialog.setWindowTitle(title) # Set up things for context help self.help_button = self.button_box.button(QtGui.QDialogButtonBox.Help) # Allow toggling the help button self.help_button.setCheckable(True) self.help_button.toggled.connect(self.help_toggled) self.main_stacked_widget.setCurrentIndex(1) # set up the validator for the file name prefix expression = QRegExp('^[A-Za-z0-9-_]*$') validator = QRegExpValidator(expression, self.filename_prefix) self.filename_prefix.setValidator(validator) self.time_stamp = None self.restore_state()
def init_controls(self): self.edtProfile.clear() self.edtDesc.clear() self.edtProfile.setFocus() name_regex = QRegExp('^[A-Za-z0-9_\s]*$') name_validator = QRegExpValidator(name_regex) self.edtProfile.setValidator(name_validator)
def __init__(self, parent=None): super(NewEntryDialog, self).__init__(parent) loadUi(__file__, self) # General window settings self.monthTab = parent.currentMonthTab() self.setWindowTitle('New Entry for \'%s\'' % self.monthTab.month()) self.setFixedSize(self.size()) # Entry name LineEdit settings strValidator = QRegExpValidator(QRegExp('.+')) self.nameLineEdit.setValidator(strValidator) completer = QCompleter(self.monthTab.entriesStringList()) completer.setCaseSensitivity(Qt.CaseInsensitive) self.nameLineEdit.setCompleter(completer) # DateEdit settings date = QDate(parent.year(), self.monthTab.monthIndex() + 1, 1) self.dateEdit.setDateRange( date, QDate(date.year(), date.month(), date.daysInMonth())) self.dateEdit.setDate(date) self.dateEdit.setCalendarPopup(True) self.dateEdit.calendarWidget().setFirstDayOfWeek(Qt.Monday) # CategoryComboBox settings self.categoryComboBox.setModel(self.monthTab.categoriesModel()) # OK PushButton settings self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) self.okButton.setEnabled(False) # CONNECTIONS self.nameLineEdit.textEdited.connect(self.setOKButton)
def setupUi(self): super(tlAddFeature, self).setupUi(self) self.setTopic.setValidator( QRegExpValidator(QRegExp("^[\$a-zA-Z0-9\-\_\/\-\#\+]+"), self)) self.setTopic.textChanged.connect(self._topicChanged) self.setName.setValidator( QRegExpValidator(QRegExp("^[\ \$a-zA-Z0-9\-\_\/\-\#\+]+"), self)) self.setName.textEdited.connect(self._setNameChanged) self.buttonAddEdit.clicked.connect(lambda: self._validateApply(True)) self.buttonAdd.clicked.connect(self._validateApply) self.buttonAddEdit.setEnabled(False) self.buttonAdd.setEnabled(False) self.setTopic.setFocus()
def validate_text(self, text): """ Validates and updates the entered text if necessary. Spaces are replaced by _ and capital letters are replaced by small. :param text: The text entered :type text: String """ text_edit = self.sender() cursor_position = text_edit.cursorPosition() text_edit.setValidator(None) if len(text) == 0: return name_regex = QRegExp('^(?=.{0,40}$)[ _a-zA-Z][a-zA-Z0-9_ ]*$') name_validator = QRegExpValidator(name_regex) text_edit.setValidator(name_validator) QApplication.processEvents() last_character = text[-1:] state = name_validator.validate(text, text.index(last_character))[0] if state != QValidator.Acceptable: self.show_notification( '"{}" is not allowed at this position.'.format(last_character)) text = text[:-1] else: # remove space and underscore at the beginning of the text if len(text) > 1: if text[0] == ' ' or text[0] == '_': text = text[1:] self.blockSignals(True) text_edit.setText(text) text_edit.setCursorPosition(cursor_position) self.blockSignals(False) text_edit.setValidator(None)
def __init__(self, format, callback, parent=None): super(NumberFormatDlg, self).__init__(parent) punctuationRe = QRegExp(r"[ ,;:.]") thousandsLabel = QLabel("&Thousands separator") self.thousandsEdit = QLineEdit(format["thousandsseparator"]) thousandsLabel.setBuddy(self.thousandsEdit) self.thousandsEdit.setMaxLength(1) self.thousandsEdit.setValidator(QRegExpValidator( punctuationRe, self)) decimalMarkerLabel = QLabel("Decimal &marker") self.decimalMarkerEdit = QLineEdit(format["decimalmarker"]) decimalMarkerLabel.setBuddy(self.decimalMarkerEdit) self.decimalMarkerEdit.setMaxLength(1) self.decimalMarkerEdit.setValidator(QRegExpValidator( punctuationRe, self)) self.decimalMarkerEdit.setInputMask("X") decimalPlacesLabel = QLabel("&Decimal places") self.decimalPlacesSpinBox = QSpinBox() decimalPlacesLabel.setBuddy(self.decimalPlacesSpinBox) self.decimalPlacesSpinBox.setRange(0, 6) self.decimalPlacesSpinBox.setValue(format["decimalplaces"]) self.redNegativesCheckBox = QCheckBox("&Red negative numbers") self.redNegativesCheckBox.setChecked(format["rednegatives"]) self.format = format self.callback = callback grid = QGridLayout() grid.addWidget(thousandsLabel, 0, 0) grid.addWidget(self.thousandsEdit, 0, 1) grid.addWidget(decimalMarkerLabel, 1, 0) grid.addWidget(self.decimalMarkerEdit, 1, 1) grid.addWidget(decimalPlacesLabel, 2, 0) grid.addWidget(self.decimalPlacesSpinBox, 2, 1) grid.addWidget(self.redNegativesCheckBox, 3, 0, 1, 2) self.setLayout(grid) self.connect(self.thousandsEdit, SIGNAL("textEdited(QString)"), self.checkAndFix) self.connect(self.decimalMarkerEdit, SIGNAL("textEdited(QString)"), self.checkAndFix) self.connect(self.decimalPlacesSpinBox, SIGNAL("valueChanged(int)"), self.apply) self.connect(self.redNegativesCheckBox, SIGNAL("toggled(bool)"), self.apply) self.setWindowTitle("Set Number Format (`Live')")
def __init__(self, parent=None): super(RomanSpinBox, self).__init__(parent) regex = QRegExp(r"^M?M?M?(?:CM|CD|D?C?C?C?)" r"(?:XC|XL|L?X?X?X?)(?:IX|IV|V?I?I?I?)$") regex.setCaseSensitivity(Qt.CaseInsensitive) self.validator = QRegExpValidator(regex, self) self.setRange(1, 3999) self.lineEdit().textEdited.connect(self.fixCase)
def __init__(self, parent=None, fixed_size=40, regex=r'.+', placeholder=None): super(InputCustomPattern, self).__init__(parent=parent) if placeholder: self.setPlaceholderText(placeholder) self.setFixedWidth(fixed_size) validator = QRegExpValidator(QRegExp(regex), self) self.setValidator(validator)
def init_controls(self): self.edtFromProfile.setText(self.orig_name) self.edtDesc.setText(self.orig_desc) self.edtName.setText(self.copy_name) self.edtName.setFocus() name_regex = QRegExp('^[A-Za-z0-9_\s]*$') name_validator = QRegExpValidator(name_regex) self.edtName.setValidator(name_validator)
def __init__(self, parent=None, iface=None): """Constructor for import dialog. :param parent: Optional widget to use as parent :type parent: QWidget :param iface: An instance of QGisInterface :type iface: QGisInterface """ QDialog.__init__(self, parent) self.parent = parent self.setupUi(self) self.setWindowTitle(self.tr('InaSAFE OpenStreetMap Downloader')) self.iface = iface self.buildings_url = 'http://osm.linfiniti.com/buildings-shp' self.building_points_url = \ 'http://osm.linfiniti.com/building-points-shp' self.roads_url = 'http://osm.linfiniti.com/roads-shp' self.help_context = 'openstreetmap_downloader' # creating progress dialog for download self.progress_dialog = QProgressDialog(self) self.progress_dialog.setAutoClose(False) title = self.tr('InaSAFE OpenStreetMap Downloader') self.progress_dialog.setWindowTitle(title) # Set up context help help_button = self.button_box.button(QtGui.QDialogButtonBox.Help) help_button.clicked.connect(self.show_help) self.show_info() # set up the validator for the file name prefix expression = QRegExp('^[A-Za-z0-9-_]*$') validator = QRegExpValidator(expression, self.filename_prefix) self.filename_prefix.setValidator(validator) # Set Proxy in webpage proxy = get_proxy() self.network_manager = QNetworkAccessManager(self) if proxy is not None: self.network_manager.setProxy(proxy) self.restore_state() # Setup the rectangle map tool self.canvas = iface.mapCanvas() self.rectangle_map_tool = \ RectangleMapTool(self.canvas) self.rectangle_map_tool.rectangle_created.connect( self.update_extent_from_rectangle) self.button_extent_rectangle.clicked.connect( self.drag_rectangle_on_map_canvas) # Setup pan tool self.pan_tool = QgsMapToolPan(self.canvas) self.canvas.setMapTool(self.pan_tool) self.update_extent_from_map_canvas()
def __init__(self, parent=None): """ Constructor """ QMainWindow.__init__(self, parent) self.setupUi(self) self.initTypeCombo() self.ids = [] self.tableSetting = None self.selectedGroup = None self.classifyMenuGroup = None regx = QRegExp("[0-9]*[\.]{0,1}[0-9]*$") validator = QRegExpValidator(regx, self) self.smallValueEdit.setValidator(validator) self.bigValueEdit.setValidator(validator) self.weightEdit.setValidator(validator) self.on_daySumRadio_clicked() self.initCmpMethCombo() self.initCmpTypeCombo() self.initCrossTypeCombo() self.filter = '' # myGlobal.init() # myGlobal.initDealDays() self.dayInfoModel = CustomModel(self) self.dayInfoModel.setRestApi('liststockdayinfo') self.dayInfoModel.setPageSize(10000) self.calcModel = CustomModel(self) self.calcModel.setRestApi('listmonthsum') self.calcModel.setPageSize(20000) self.calcModel2 = CustomModel(self) self.calcModel2.setRestApi('liststockdaysdiff') self.calcModel2.setPageSize(10000) self.crossModel = CustomModel(self) self.crossModel.setRestApi('listcrossinfo') self.crossModel.setPageSize(10000) self.combineModel = CombineModel(self) self.combineModel.setPageSize(10000) self.classifyMenu = None self.endDate = QDate.currentDate() self.startDate = self.endDate.addDays(-1) self.calcTableWidget.setButtonsVisible(False) self.combineWidget.setButtonsVisible(False) self.combineWidget.clearBtn.setVisible(True) self.combineWidget.undoBtn.setVisible(True) #self.treeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu); savedSetting = config.readSetting() if 'groups' in savedSetting: self.groups = savedSetting['groups'] else: self.groups = {} self.updateFilter() self.listWidget.setVisible(False) self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.modifyDateEdit() self.showGroupBtn.setChecked(True) self.on_showGroupBtn_clicked() self.showMaximized()
def __init__(self, tree, dataset, master, parent=None): QLineEdit.__init__(self, parent) Control.__init__(self, tree, dataset, master) if hasattr(tree, "regexp"): self.setValidator(QRegExpValidator(QRegExp(tree.regexp), self)) if hasattr(tree, "defaultValue"): self.setText(tree.defaultValue)
def __setup_ui(self): self.setMaximumSize(300, 200) self.setMinimumSize(300, 200) vlayout = QVBoxLayout() host_layout = QHBoxLayout() port_layout = QHBoxLayout() schema_layout = QHBoxLayout() btn_layout = QHBoxLayout() host_layout.addWidget(QLabel('Host'), 3) #self.__host_edit = QLineEdit('192.168.184.128') self.__host_edit = QLineEdit() self.__host_edit.setValidator(QRegExpValidator(self.__host_reg)) host_layout.addWidget(self.__host_edit, 7) port_layout.addWidget(QLabel('Port'), 3) #self.__port_edit = QLineEdit('6641') self.__port_edit = QLineEdit() self.__port_edit.setValidator(QRegExpValidator(self.__port_reg)) port_layout.addWidget(self.__port_edit, 7) schema_layout.addWidget(QLabel('Schema'), 3) self.__schema_combo_box = QComboBox() self.__schema_combo_box.addItems( QStringList() << 'Open_vSwitch' << 'OVN_Northbound' << 'OVN_Southbound' << 'hardware_vtep') self.__schema_combo_box.view().setSpacing(3) #self.__schema_combo_box.setCurrentIndex(1) schema_layout.addWidget(self.__schema_combo_box, 7) self.ok_btn = QPushButton('ok') #self.ok_btn.setFlat(True) self.ok_btn.setEnabled(False) self.cancel_btn = QPushButton('cancel') btn_layout.addWidget(self.ok_btn, 5) btn_layout.addWidget(self.cancel_btn, 5) vlayout.addLayout(host_layout) vlayout.addLayout(port_layout) vlayout.addLayout(schema_layout) vlayout.addLayout(btn_layout) self.setLayout(vlayout)
def createEditor(self, widget, option, index): if not index.isValid(): return 0 if index.column() == 0: #only on the cells in the first column editor = QLineEdit(widget) # accept only numbers from 0-200 validator = QRegExpValidator(QRegExp("2\d\d|1\d\d|\d\d|\d"), editor) editor.setValidator(validator) return editor return super(ValidatedItemDelegate, self).createEditor(widget, option, index)
def __init__(self): QDialog.__init__(self) QIcon.setThemeName("Adwaita") self.setWindowIcon(QIcon.fromTheme("document-print")) self.setupUi(self) self.resize(640, 480) self.setWindowTitle("QuikPrint " + __version__) self.settings = QSettings(self) # Create and setup widgets self.widthSpin.setHidden(True) self.heightSpin.setHidden(True) rangeValidator = QRegExpValidator(self.pagerangeEdit) rangeValidator.setRegExp( QRegExp('([0-9,-])*')) # TODO : check validity of whole string self.pagerangeEdit.setValidator(rangeValidator) # Set values printers = self.getPrinters() if printers == []: QMessageBox.critical(self, 'Error !', 'No Printers added', 'Close') return QDialog.accept(self) self.printersCombo.addItems(printers) # select default printer options default_printer = get_default_printer() selected_index = 0 for i, printer in enumerate(printers): if printer == default_printer: selected_index = i break self.printersCombo.setCurrentIndex(selected_index) self.selectPrinter(selected_index) # get printer independent options fit_to_page = True if self.settings.value("FitToPage", "false") == 'true' else False self.fitToPageBtn.setChecked(fit_to_page) brightness = int(self.settings.value("Brightness", 100)) gamma = int(self.settings.value("Gamma", 1000)) ppi = int(self.settings.value("PPI", 300)) natural_scaling = int(self.settings.value("NaturalScaling", 100)) scaling = int(self.settings.value("Scaling", 100)) paper_w = int(self.settings.value("PaperW", 100)) paper_h = int(self.settings.value("PaperH", 100)) self.brightnessSpin.setValue(brightness) self.gammaSpin.setValue(gamma) self.ppiSpin.setValue(ppi) self.naturalScalingSpin.setValue(natural_scaling) self.scalingSpin.setValue(scaling) self.widthSpin.setValue(paper_w) self.heightSpin.setValue(paper_h) # Connect Signals self.printersCombo.currentIndexChanged.connect(self.selectPrinter) self.paperSizeCombo.currentIndexChanged.connect(self.onPaperSizeChange) self.pixelDensityBtn.clicked.connect(self.onDensityBtnClick) self.printBtn.clicked.connect(self.accept) self.quitBtn.clicked.connect(self.reject) self.cancelJobsBtn.clicked.connect(self.cancelPrintJobs)
def __init__(self, parent=None): super(LM_DoubleSpinBox_with_calc, self).__init__(parent) #setup a special validator (allowed are leading '=', 0-9 , . ( ) * / + - ... no caracters ... excel-like self.validator = QRegExpValidator( QRegExp("(^={1}\d*([-+*/(),.]*\d*)*)|([0-9,.])*")) self.expression = "" # this is the variable which holds the expression self.setSpecialValueText( "" ) # this is only an action to avoid error messages if the field is empty self.setCorrectionMode(QAbstractSpinBox.CorrectToPreviousValue) self.canBeCommitted = True #this variable holds the status, if the user has entered a valid formula or not
def __init__(self, parent=None): super(NewStudentDialog, self).__init__(parent) self.setMinimumWidth(300) self.setWindowTitle(_('Add a new student')) layout = QFormLayout() self.setLayout(layout) self.id_field = QLineEdit(self) self.id_field.setValidator(QRegExpValidator(QRegExp(r'\d+'), self)) self.id_field.textEdited.connect(self._check_values) self.name_field = QLineEdit(self) self.surname_field = QLineEdit(self) self.full_name_field = QLineEdit(self) self.name_label = QLabel(_('Given name')) self.surname_label = QLabel(_('Surname')) self.full_name_label = QLabel(_('Full name')) self.email_field = QLineEdit(self) self.email_field.setValidator( \ QRegExpValidator(QRegExp(utils.re_exp_email), self)) self.email_field.textEdited.connect(self._check_values) self.combo = QComboBox(parent=self) self.combo.addItem(_('Separate given name and surname')) self.combo.addItem(_('Full name in just one field')) self.combo.currentIndexChanged.connect(self._update_combo) layout.addRow(self.combo) layout.addRow(_('Id number'), self.id_field) layout.addRow(self.name_label, self.name_field) layout.addRow(self.surname_label, self.surname_field) layout.addRow(self.full_name_label, self.full_name_field) layout.addRow(_('Email'), self.email_field) self.buttons = QDialogButtonBox((QDialogButtonBox.Ok | QDialogButtonBox.Cancel)) layout.addRow(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self._check_values() # Set the combo box if NewStudentDialog._last_combo_value is None: NewStudentDialog._last_combo_value = 0 self.combo.setCurrentIndex(NewStudentDialog._last_combo_value) self._update_combo(NewStudentDialog._last_combo_value)
def __init__(self, parent=None, minimum_width=100, is_positive=True): super(InputScore, self).__init__(parent=parent) self.setMinimumWidth(minimum_width) if is_positive: placeholder = _('e.g.: 2; 2.5; 5/2') else: placeholder = _('e.g.: 0; -1; -1.25; -5/4') self.setPlaceholderText(placeholder) regex = r'((\d*(\.\d+))|(\d+\/\d+))' if not is_positive: regex = '-?' + regex validator = QRegExpValidator(QRegExp(regex), self) self.setValidator(validator)
def createWidgets(self, layout): self.label = QLabel(wordWrap=True) self.voicingLabel = QLabel() self.voicing = QComboBox(editable=True) self.voicingLabel.setBuddy(self.voicing) self.voicing.setCompleter(None) self.voicing.setValidator( QRegExpValidator(QRegExp("[SATB]+(-[SATB]+)*", Qt.CaseInsensitive), self.voicing)) self.voicing.addItems(( 'SA-TB', 'S-A-T-B', 'SA', 'S-A', 'SS-A', 'S-S-A', 'TB', 'T-B', 'TT-B', 'T-T-B', 'SS-A-T-B', 'S-A-TT-B', 'SS-A-TT-B', 'S-S-A-T-T-B', 'S-S-A-A-T-T-B-B', )) self.lyricsLabel = QLabel() self.lyrics = QComboBox() self.lyricsLabel.setBuddy(self.lyrics) self.lyrics.setModel( listmodel.ListModel(lyricStyles, self.lyrics, display=listmodel.translate_index(0), tooltip=listmodel.translate_index(1))) self.lyrics.setCurrentIndex(0) self.pianoReduction = QCheckBox() self.rehearsalMidi = QCheckBox() layout.addWidget(self.label) box = QHBoxLayout() layout.addLayout(box) box.addWidget(self.voicingLabel) box.addWidget(self.voicing) self.createStanzaWidget(layout) box = QHBoxLayout() layout.addLayout(box) box.addWidget(self.lyricsLabel) box.addWidget(self.lyrics) self.createAmbitusWidget(layout) layout.addWidget(self.pianoReduction) layout.addWidget(self.rehearsalMidi)
def __init__(self, parent=None): super(GotocellDialog, self).__init__(parent) self.setupUi(self) # 允许 一个大写或者小写的字母,后面跟着一个范围1~9的数字, # 后面再跟0个,1个或 2个0~9的数字(对于正则表达式的介绍,请查看文档中QRegExp类) regExp = QRegExp("[A-Za-z][1-9][0-9]{0,2}") self.lineEdit.setValidator(QRegExpValidator(regExp, self)) self.connect(self.okButton, SIGNAL("clicked()"), self, SLOT("accept()")) self.connect(self.cancelButton, SIGNAL("clicked()"), self, SLOT("reject()"))