def __init__(self, parent, start, stop): super().__init__(parent) self.setWindowTitle("Crop data") vbox = QVBoxLayout(self) grid = QGridLayout() self.start_checkbox = QCheckBox("Start time:") self.start_checkbox.setChecked(True) self.start_checkbox.stateChanged.connect(self.toggle_start) grid.addWidget(self.start_checkbox, 0, 0) self._start = QDoubleSpinBox() self._start.setMaximum(999999) self._start.setValue(start) self._start.setDecimals(2) self._start.setSuffix(" s") grid.addWidget(self._start, 0, 1) self.stop_checkbox = QCheckBox("Stop time:") self.stop_checkbox.setChecked(True) self.stop_checkbox.stateChanged.connect(self.toggle_stop) grid.addWidget(self.stop_checkbox, 1, 0) self._stop = QDoubleSpinBox() self._stop.setMaximum(999999) self._stop.setValue(stop) self._stop.setDecimals(2) self._stop.setSuffix(" s") grid.addWidget(self._stop, 1, 1) vbox.addLayout(grid) buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(buttonbox) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) vbox.setSizeConstraint(QVBoxLayout.SetFixedSize)
def __init__(self): super(FindToolBar, self).__init__() self._line_edit = QLineEdit() self._line_edit.setClearButtonEnabled(True) self._line_edit.setPlaceholderText("Find...") self._line_edit.setMaximumWidth(300) self._line_edit.returnPressed.connect(self._find_next) self.addWidget(self._line_edit) self._previous_button = QToolButton() style_icons = ':/qt-project.org/styles/commonstyle/images/' self._previous_button.setIcon(QIcon(style_icons + 'up-32.png')) self._previous_button.clicked.connect(self._find_previous) self.addWidget(self._previous_button) self._next_button = QToolButton() self._next_button.setIcon(QIcon(style_icons + 'down-32.png')) self._next_button.clicked.connect(self._find_next) self.addWidget(self._next_button) self._case_sensitive_checkbox = QCheckBox('Case Sensitive') self.addWidget(self._case_sensitive_checkbox) self._hideButton = QToolButton() self._hideButton.setShortcut(QKeySequence(Qt.Key_Escape)) self._hideButton.setIcon(QIcon(style_icons + 'closedock-16.png')) self._hideButton.clicked.connect(self.hide) self.addWidget(self._hideButton)
def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("My App") checkBox = QCheckBox("This is a checkbox") checkBox.setCheckable(Qt.Checked) checkBox.stateChanged.connect(self.show_state) self.setCentralWidget(checkBox)
class OptionalCurrencyComboBox(QWidget): changed = Signal() name_updated = Signal(str) def __init__(self, parent): QWidget.__init__(self, parent) self._id = 0 self.layout = QHBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.null_flag = QCheckBox(parent) self.null_flag.setChecked(False) self.null_flag.setText(self.tr("Currency")) self.layout.addWidget(self.null_flag) self.currency = CurrencyComboBox(parent) self.currency.setEnabled(False) self.layout.addWidget(self.currency) self.setLayout(self.layout) self.setFocusProxy(self.null_flag) self.null_flag.clicked.connect(self.onClick) self.currency.changed.connect(self.onCurrencyChange) def setText(self, text): self.null_flag.setText(text) def getId(self): return self._id if self._id else None def setId(self, new_value): if self._id == new_value: return self._id = new_value self.updateView() name = JalDB().get_asset_name(self._id) self.name_updated.emit('' if name is None else name) currency_id = Property(int, getId, setId, notify=changed, user=True) def updateView(self): has_value = True if self._id else False if has_value: self.currency.selected_id = self._id self.null_flag.setChecked(has_value) self.currency.setEnabled(has_value) @Slot() def onClick(self): if self.null_flag.isChecked(): if self.currency.selected_id == 0: self.currency.selected_id = JalSettings().getValue('BaseCurrency') self.currency_id = self.currency.selected_id else: self.currency_id = 0 self.changed.emit() @Slot() def onCurrencyChange(self, _id): self.currency_id = self.currency.selected_id self.changed.emit()
def __init__(self, parent, rows, selected=None, disabled=None): super().__init__(parent) self.setWindowTitle("Select XDF Stream") self.model = QStandardItemModel() self.model.setHorizontalHeaderLabels( ["ID", "Name", "Type", "Channels", "Format", "Sampling Rate"]) for index, stream in enumerate(rows): items = [] for item in stream: tmp = QStandardItem() tmp.setData(item, Qt.DisplayRole) items.append(tmp) for item in items: item.setEditable(False) if disabled is not None and index in disabled: item.setFlags(Qt.NoItemFlags) self.model.appendRow(items) self.view = QTableView() self.view.setModel(self.model) self.view.verticalHeader().setVisible(False) self.view.horizontalHeader().setStretchLastSection(True) self.view.setShowGrid(False) self.view.setSelectionMode(QAbstractItemView.SingleSelection) self.view.setSelectionBehavior(QAbstractItemView.SelectRows) if selected is not None: self.view.selectRow(selected) self.view.setSortingEnabled(True) self.view.sortByColumn(0, Qt.AscendingOrder) vbox = QVBoxLayout(self) vbox.addWidget(self.view) hbox = QHBoxLayout() self._effective_srate = QCheckBox("Use effective sampling rate") self._effective_srate.setChecked(True) hbox.addWidget(self._effective_srate) self._prefix_markers = QCheckBox("Prefix markers with stream ID") self._prefix_markers.setChecked(False) if not disabled: self._prefix_markers.setEnabled(False) hbox.addWidget(self._prefix_markers) vbox.addLayout(hbox) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(self.buttonbox) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) self.resize(775, 650) self.view.setColumnWidth(0, 90) self.view.setColumnWidth(1, 200) self.view.setColumnWidth(2, 140)
def init_add_suffix_checkbox(self): """ Initialize the layout for add suffix checkbox """ self.add_suffix_checkbox = QCheckBox() self.add_suffix_checkbox.setObjectName("AddSuffixCheckBox") self.add_suffix_checkbox.setChecked(self.add_suffix) self.add_suffix_checkbox.clicked.connect( self.add_suffix_checkbox_clicked) self.transfer_roi_window_grid_layout.addWidget( self.add_suffix_checkbox, 3, 0)
class InterpolateBadsDialog(QDialog): def __init__(self, parent): super().__init__(parent) self.setWindowTitle("Interpolate bad channels") vbox = QVBoxLayout(self) grid = QGridLayout() grid.addWidget(QLabel("Reset bads:"), 0, 0) self.reset_bads_checkbox = QCheckBox() self.reset_bads_checkbox.setChecked(True) grid.addWidget(self.reset_bads_checkbox, 0, 1) grid.addWidget(QLabel("Mode:"), 1, 0) self.mode_select = QComboBox() self.modes = {"Accurate": "accurate", "Fast": "fast"} self.mode_select.addItems(self.modes.keys()) self.mode_select.setCurrentText("Accurate") grid.addWidget(self.mode_select, 1, 1) grid.addWidget(QLabel("Origin (x, y, z):"), 2, 0) hbox = QHBoxLayout() self.x = QDoubleSpinBox() self.x.setValue(0) self.x.setDecimals(3) hbox.addWidget(self.x) self.y = QDoubleSpinBox() self.y.setValue(0) self.y.setDecimals(3) hbox.addWidget(self.y) self.z = QDoubleSpinBox() self.z.setValue(0.04) self.z.setDecimals(3) hbox.addWidget(self.z) grid.addLayout(hbox, 2, 1) vbox.addLayout(grid) buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(buttonbox) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) vbox.setSizeConstraint(QVBoxLayout.SetFixedSize) @property def origin(self): x = float(self.x.value()) y = float(self.y.value()) z = float(self.z.value()) return x, y, z @property def mode(self): return self.mode_select.currentText() @property def reset_bads(self): return self.reset_bads_checkbox.isChecked()
def __init__(self, parent=None): super(Window, self).__init__(parent) self.iconGroupBox = QGroupBox() self.iconLabel = QLabel() self.iconComboBox = QComboBox() self.showIconCheckBox = QCheckBox() self.messageGroupBox = QGroupBox() self.typeLabel = QLabel() self.durationLabel = QLabel() self.durationWarningLabel = QLabel() self.titleLabel = QLabel() self.bodyLabel = QLabel() self.typeComboBox = QComboBox() self.durationSpinBox = QSpinBox() self.titleEdit = QLineEdit() self.bodyEdit = QTextEdit() self.showMessageButton = QPushButton() self.minimizeAction = QAction() self.maximizeAction = QAction() self.restoreAction = QAction() self.quitAction = QAction() self.trayIcon = QSystemTrayIcon() self.trayIconMenu = QMenu() self.createIconGroupBox() self.createMessageGroupBox() self.iconLabel.setMinimumWidth(self.durationLabel.sizeHint().width()) self.createActions() self.createTrayIcon() self.showMessageButton.clicked.connect(self.showMessage) self.showIconCheckBox.toggled.connect(self.trayIcon.setVisible) self.iconComboBox.currentIndexChanged.connect(self.setIcon) self.trayIcon.messageClicked.connect(self.messageClicked) self.trayIcon.activated.connect(self.iconActivated) self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.iconGroupBox) self.mainLayout.addWidget(self.messageGroupBox) self.setLayout(self.mainLayout) self.iconComboBox.setCurrentIndex(1) self.trayIcon.show() self.setWindowTitle("Systray") self.resize(400, 300)
class TabMain(QWidget): def __init__(self) -> None: super().__init__() # member self.pathname_line = PathLine() self.checkbox_save_to_file = QCheckBox("Save to File") self.t_button_open_filedialog = create_tool_button( is_text_beside_icon=True) self.t_button_step_mode = create_tool_button(fixed_width=250) self.t_button_cycle_mode = create_tool_button(fixed_width=250) self.t_button_only_lcr_mode = create_tool_button(fixed_width=250) self.t_button_lcr_state = create_tool_button(fixed_width=250) self.spinbox_interval = QSpinBox() self.group_save = QGroupBox("Save") self.group_mode = QGroupBox("Mode") self.group_lcr_state = QGroupBox("LCR Meter") self.group_measure_interval = QGroupBox("Measurement Interval") # setup self.spinbox_interval.setRange(1, 100000) self.checkbox_save_to_file.setEnabled(False) # setup layout f_layout_save = QFormLayout() f_layout_save.addRow("File Path", self.pathname_line) f_layout_save.addWidget(self.t_button_open_filedialog) f_layout_save.addRow(self.checkbox_save_to_file) self.group_save.setLayout(f_layout_save) v_layout_mode = AVBoxLayout() v_layout_mode.addWidget(self.t_button_step_mode) v_layout_mode.addWidget(self.t_button_cycle_mode) v_layout_mode.addWidget(self.t_button_only_lcr_mode) v_layout_mode.setAlignment(Qt.AlignHCenter) self.group_mode.setLayout(v_layout_mode) v_layout_lcr_state = AVBoxLayout() v_layout_lcr_state.addWidget(self.t_button_lcr_state) v_layout_lcr_state.setAlignment(Qt.AlignHCenter) self.group_lcr_state.setLayout(v_layout_lcr_state) f_layout_repeat = QFormLayout() f_layout_repeat.addRow("Interval", add_unit(self.spinbox_interval, "msec")) self.group_measure_interval.setLayout(f_layout_repeat) v_layout = AVBoxLayout(self) v_layout.addWidget(self.group_save) v_layout.addWidget(self.group_mode) v_layout.addWidget(self.group_lcr_state) v_layout.addWidget(self.group_measure_interval)
def __init__(self, parent, events): super().__init__(parent) self.setWindowTitle("Create Epochs") grid = QGridLayout(self) label = QLabel("Events:") label.setAlignment(Qt.AlignTop) grid.addWidget(label, 0, 0, 1, 1) self.events = QListWidget() self.events.insertItems(0, unique(events[:, 2]).astype(str)) self.events.setSelectionMode(QListWidget.ExtendedSelection) grid.addWidget(self.events, 0, 1, 1, 2) grid.addWidget(QLabel("Interval around events:"), 1, 0, 1, 1) self.tmin = QDoubleSpinBox() self.tmin.setMinimum(-10000) self.tmin.setValue(-0.2) self.tmin.setSingleStep(0.1) self.tmin.setAlignment(Qt.AlignRight) self.tmax = QDoubleSpinBox() self.tmax.setMinimum(-10000) self.tmax.setValue(0.5) self.tmax.setSingleStep(0.1) self.tmax.setAlignment(Qt.AlignRight) grid.addWidget(self.tmin, 1, 1, 1, 1) grid.addWidget(self.tmax, 1, 2, 1, 1) self.baseline = QCheckBox("Baseline Correction:") self.baseline.setChecked(True) self.baseline.stateChanged.connect(self.toggle_baseline) grid.addWidget(self.baseline, 2, 0, 1, 1) self.a = QDoubleSpinBox() self.a.setMinimum(-10000) self.a.setValue(-0.2) self.a.setSingleStep(0.1) self.a.setAlignment(Qt.AlignRight) self.b = QDoubleSpinBox() self.b.setMinimum(-10000) self.b.setValue(0) self.b.setSingleStep(0.1) self.b.setAlignment(Qt.AlignRight) grid.addWidget(self.a, 2, 1, 1, 1) grid.addWidget(self.b, 2, 2, 1, 1) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) grid.addWidget(self.buttonbox, 3, 0, 1, -1) self.events.itemSelectionChanged.connect(self.toggle_ok) self.toggle_ok() grid.setSizeConstraint(QGridLayout.SetFixedSize)
class LoginBuilder(object): """Constructs a login window.""" def setup(self, dialog): dialog.resize(320, 132) dialog.setModal(True) dialog.setWindowTitle("Please Login to Continue") self.form_layout = QFormLayout(dialog) self.form_layout.setObjectName("formLayout") self.login_label = QLabel("Server requesting authentication", dialog) self.login_label.setObjectName("login_label") self.form_layout.setWidget(0, QFormLayout.SpanningRole, self.login_label) self.username_label = QLabel(dialog) self.username_label.setObjectName("username_label") self.form_layout.setWidget(1, QFormLayout.LabelRole, self.username_label) self.username = QLineEdit(dialog) self.username.setObjectName("username") self.username.setStatusTip("Enter your username.") self.form_layout.setWidget(1, QFormLayout.FieldRole, self.username) self.password_label = QLabel(dialog) self.password_label.setObjectName("password_label") self.form_layout.setWidget(2, QFormLayout.LabelRole, self.password_label) self.password = QLineEdit(dialog) self.password.setObjectName("password") self.password.setStatusTip("Enter your password.") self.password.setEchoMode(QLineEdit.PasswordEchoOnEdit) self.form_layout.setWidget(2, QFormLayout.FieldRole, self.password) self.save_username = QCheckBox("&Save username", dialog) self.save_username.setObjectName("save_username") self.form_layout.setWidget(3, QFormLayout.FieldRole, self.save_username) self.button_box = QDialogButtonBox(dialog) self.button_box.setObjectName("button_box") self.button_box.setOrientation(Qt.Horizontal) self.button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.form_layout.setWidget(4, QFormLayout.SpanningRole, self.button_box) self.button_box.accepted.connect(dialog.accept) self.button_box.rejected.connect(dialog.close) QMetaObject.connectSlotsByName(dialog)
def set_item_data(self, i, DisplayName, name, sid): check_box_layout = QHBoxLayout() check_box_layout.setAlignment(Qt.AlignmentFlag.AlignCenter) check_box = QCheckBox() check_box.setObjectName('check_box_' + str(i)) check_box_layout.addWidget(check_box) check_box_layout.setContentsMargins(0, 0, 0, 0) check_box_widget = QWidget() check_box_widget.setLayout(check_box_layout) self.tableWidget.item(i, 2).setText(DisplayName) self.tableWidget.item(i, 3).setText(name) self.tableWidget.item(i, 4).setText(sid) self.tableWidget.setCellWidget(i, 0, check_box_widget)
class Ui_SelectAccountDlg(object): def setupUi(self, SelectAccountDlg): if not SelectAccountDlg.objectName(): SelectAccountDlg.setObjectName(u"SelectAccountDlg") SelectAccountDlg.resize(400, 141) self.verticalLayout = QVBoxLayout(SelectAccountDlg) self.verticalLayout.setObjectName(u"verticalLayout") self.DescriptionLbl = QLabel(SelectAccountDlg) self.DescriptionLbl.setObjectName(u"DescriptionLbl") self.verticalLayout.addWidget(self.DescriptionLbl) self.AccountWidget = AccountSelector(SelectAccountDlg) self.AccountWidget.setObjectName(u"AccountWidget") self.verticalLayout.addWidget(self.AccountWidget) self.ReuseAccount = QCheckBox(SelectAccountDlg) self.ReuseAccount.setObjectName(u"ReuseAccount") self.verticalLayout.addWidget(self.ReuseAccount) self.buttonBox = QDialogButtonBox(SelectAccountDlg) self.buttonBox.setObjectName(u"buttonBox") self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(self.verticalSpacer) self.retranslateUi(SelectAccountDlg) self.buttonBox.accepted.connect(SelectAccountDlg.close) QMetaObject.connectSlotsByName(SelectAccountDlg) # setupUi def retranslateUi(self, SelectAccountDlg): SelectAccountDlg.setWindowTitle( QCoreApplication.translate("SelectAccountDlg", u"Please select account", None)) self.DescriptionLbl.setText( QCoreApplication.translate("SelectAccountDlg", u"TextLabel", None)) self.ReuseAccount.setText( QCoreApplication.translate( "SelectAccountDlg", u"Use the same account for given currency", None))
def on_click_set_part(self, ent_part: QLineEdit, combo_1: QComboBox, check: QCheckBox, ent_desc: QLineEdit, combo_2: QComboBox): # obtain part number num_part = ent_part.text() ent_part.setText(None) # obtain original part number if selected id_part_orig = 'NULL' if combo_1.isEnabled(): num_part_org = combo_1.currentText() sql1 = self.db.sql( "SELECT id_part FROM part WHERE num_part = '?';", [num_part_org]) print(sql1) out = self.db.get(sql1) for id in out: id_part_orig = id[0] combo_1.clear() combo_1.clearEditText() combo_1.setEnabled(False) # clear QCheckBox if check.isChecked(): check.setEnabled(False) # obtain part description description = ent_desc.text() ent_desc.setText(None) # obtain id_supplier from selected supplier on the QComboBox supplier = combo_2.currentText() sql2 = self.db.sql( "SELECT id_supplier FROM supplier WHERE name_supplier_short = '?';", [supplier]) print(sql2) out = self.db.get(sql2) for id in out: id_supplier = id[0] print(num_part) print(description) print(supplier) print(id_supplier) # insert new part to part table sql3 = self.db.sql( "INSERT INTO part VALUES(NULL, ?, ?, '?', '?', NULL, NULL);", [id_part_orig, id_supplier, num_part, description]) print(sql3) self.db.put(sql3)
class TabLCR(QWidget): def __init__(self) -> None: super().__init__() # member self.combobox_parameter1 = IM3536ParameterCombobox() self.combobox_parameter2 = IM3536ParameterCombobox() self.combobox_parameter3 = IM3536ParameterCombobox() self.combobox_parameter4 = IM3536ParameterCombobox() self.spinbox_measurements_num = QSpinBox() self.checkbox_parmanent = QCheckBox("Parmanent Measurement") self.checkbox_acquire_monitor_data = QCheckBox( "Acquire Voltage/Current Monitor Values") self.group_parameter = QGroupBox("Parameter") self.group_only_lcr = QGroupBox("Only LCR Meter Mode") self.group_option = QGroupBox("Option") # setup self.combobox_parameter1.setCurrentText( "Rs (Equivalent series resistance)") self.combobox_parameter1.set_none_disabled(True) self.spinbox_measurements_num.setRange(1, 1000000000) self.checkbox_acquire_monitor_data.setChecked(True) self.checkbox_parmanent.setChecked(True) self.spinbox_measurements_num.setEnabled(False) self.group_only_lcr.setEnabled(False) # stup layout f_layout_parameter = QFormLayout() f_layout_parameter.addRow("1", self.combobox_parameter1) f_layout_parameter.addRow("2", self.combobox_parameter2) f_layout_parameter.addRow("3", self.combobox_parameter3) f_layout_parameter.addRow("4", self.combobox_parameter4) self.group_parameter.setLayout(f_layout_parameter) f_layout_only_lcr = QFormLayout() f_layout_only_lcr.addRow(self.checkbox_parmanent) f_layout_only_lcr.addRow("Number of Measurements", self.spinbox_measurements_num) self.group_only_lcr.setLayout(f_layout_only_lcr) f_layout_option = QFormLayout() f_layout_option.addRow(self.checkbox_acquire_monitor_data) self.group_option.setLayout(f_layout_option) v_layout = AVBoxLayout(self) v_layout.addWidget(self.group_parameter) v_layout.addWidget(self.group_only_lcr) v_layout.addWidget(self.group_option)
def _on_patch_checkbox_changed(self, field_name: str, checkbox: QCheckBox, value: int): with self._editor as editor: patch_configuration = editor.configuration.patches new_config = dataclasses.replace( patch_configuration, **{field_name: checkbox.isChecked()}) editor.set_configuration_field("patches", new_config)
def __init__(self, parent=None): super(Maker, self).__init__(parent) self.setWindowTitle("Project Maker") self.userFilepath = QLineEdit() self.userFilepath.setPlaceholderText("Your filepath here...") self.projName = QLineEdit() self.projName.setPlaceholderText("Your project name here...") self.makeButton = QPushButton("Create Project") self.fileSearchButton = QPushButton("...") self.fileSearchButton.setToolTip( "Search for a directory for your project") self.goProj = QRadioButton("Go Project") self.goProj.setToolTip("You will still need a go.mod file") self.pyProj = QRadioButton("Python Project") self.versionControlFiles = QCheckBox( "Create README.md and .gitignore?") self.versionControlFiles.setToolTip( "Creates the files used in online version control, such as Github") self.pyProj.setChecked(True) self.versionControlFiles.setChecked(True) projSelect = QGroupBox("Project Selection") projectOptions = QVBoxLayout() projectOptions.addWidget(self.pyProj) projectOptions.addWidget(self.goProj) projectOptions.addWidget(self.versionControlFiles) projectOptions.stretch(1) projSelect.setLayout(projectOptions) searchLayout = QHBoxLayout() searchLayout.addWidget(self.userFilepath) searchLayout.addWidget(self.fileSearchButton) searchLayout.stretch(1) layout = QVBoxLayout() layout.addLayout(searchLayout) layout.addWidget(self.projName) layout.addWidget(self.makeButton) layout.addWidget(self.fileSearchButton) layout.addWidget(projSelect) self.setLayout(layout) self.makeButton.clicked.connect(self.createFiles) self.fileSearchButton.clicked.connect(self.onClickFileSearch)
def __init__(self, parent, trigger_data): super().__init__(parent) self.trigger_data = trigger_data self.tag = self.trigger_data.get('Tag') self.uuid = str(uuid4()) self.path = self.parent().path / 'img' self.name = QLineEdit(self.trigger_data.get('Name', '')) self.search_text = QLineEdit(self.trigger_data.get('SearchText', '')) self.alert_text = QLineEdit(self.trigger_data.get('AlertText', '')) self.use_audio = QCheckBox() self.use_audio.setChecked( eval(self.trigger_data.get('UseAudio', 'False'))) self.button_box = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Save) self.button_box.accepted.connect(self.save) self.button_box.rejected.connect(self.reject) self.create_gui()
def __init__(self, parent): QWidget.__init__(self, parent) self._id = 0 self.layout = QHBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.null_flag = QCheckBox(parent) self.null_flag.setChecked(False) self.null_flag.setText(self.tr("Currency")) self.layout.addWidget(self.null_flag) self.currency = CurrencyComboBox(parent) self.currency.setEnabled(False) self.layout.addWidget(self.currency) self.setLayout(self.layout) self.setFocusProxy(self.null_flag) self.null_flag.clicked.connect(self.onClick) self.currency.changed.connect(self.onCurrencyChange)
def setup_plugins_tab(self) -> None: self.plugins = get_plugins() self.plugin_checkboxes = {} for plugin in self.plugins: checkbox = QCheckBox() checkbox.setChecked(plugin.enabled) self.plugin_checkboxes[plugin.get_settings_name()] = checkbox self.ui.gridLayoutPlugins.addWidget(checkbox) self.ui.gridLayoutPlugins.addWidget(QLabel(plugin.name)) self.ui.gridLayoutPlugins.addWidget(QLabel(plugin.description)) # Add spacer to fill the remaining space self.ui.gridLayoutPlugins.addItem( QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.ui.pushButtonReloadPlugins.clicked.connect( self.slot_reload_plugins)
class TriggerDialog(QDialog): def __init__(self, parent, trigger_data): super().__init__(parent) self.trigger_data = trigger_data self.tag = self.trigger_data.get('Tag') self.uuid = str(uuid4()) self.path = self.parent().path / 'img' self.name = QLineEdit(self.trigger_data.get('Name', '')) self.search_text = QLineEdit(self.trigger_data.get('SearchText', '')) self.alert_text = QLineEdit(self.trigger_data.get('AlertText', '')) self.use_audio = QCheckBox() self.use_audio.setChecked( eval(self.trigger_data.get('UseAudio', 'False'))) self.button_box = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Save) self.button_box.accepted.connect(self.save) self.button_box.rejected.connect(self.reject) self.create_gui() def create_gui(self): self.setWindowTitle('Trigger Editor') icon_path = self.path / 'trigger.png' icon = QIcon(str(icon_path.resolve())) self.setWindowIcon(icon) form_layout = QFormLayout() form_layout.addRow('Trigger Name:', self.name) form_layout.addRow('Search Text:', self.search_text) form_layout.addRow('Alert Text:', self.alert_text) form_layout.addRow('Use Audio:', self.use_audio) form_layout.addRow(self.button_box) self.setLayout(form_layout) self.open() @Slot() def save(self): self.trigger_data = { 'Tag': self.tag, 'Name': self.name.text(), 'SearchText': self.search_text.text(), 'AlertText': self.alert_text.text(), 'UseAudio': str(self.use_audio.isChecked()), 'id': self.uuid } self.accept()
def _dismissableMessage(parent: Optional[QWidget], message: str, icon: QIcon, buttons: QMessageBox.StandardButton, dismissed_messages: MutableMapping[ str, QMessageBox.StandardButton]) -> QMessageBox.StandardButton: if message in dismissed_messages: return dismissed_messages[message] message_box = QMessageBox(icon, QApplication.applicationName(), message, buttons, parent) checkbox = QCheckBox(message_box) checkbox.setText('Don\'t warn again') message_box.setCheckBox(checkbox) button = message_box.exec() if checkbox.isChecked(): dismissed_messages[message] = button return button
def createIconGroupBox(self): self.iconGroupBox = QGroupBox("Tray Icon") self.iconLabel = QLabel("Icon:") self.iconComboBox = QComboBox() self.iconComboBox.addItem(QIcon(":/images/bad.png"), "Bad") self.iconComboBox.addItem(QIcon(":/images/heart.png"), "Heart") self.iconComboBox.addItem(QIcon(":/images/trash.png"), "Trash") self.showIconCheckBox = QCheckBox("Show icon") self.showIconCheckBox.setChecked(True) iconLayout = QHBoxLayout() iconLayout.addWidget(self.iconLabel) iconLayout.addWidget(self.iconComboBox) iconLayout.addStretch() iconLayout.addWidget(self.showIconCheckBox) self.iconGroupBox.setLayout(iconLayout)
class Item(QWidget): item_finished_signal = Signal(int) item_commit_signal = Signal(int) item_tab_pressed_signal = Signal(int) def __init__(self, index, level=0, text=None): super().__init__() self.index = index self.level = level self.layout = QHBoxLayout() self.checkbox = QCheckBox() self.lineedit = QLineEdit() self.checkbox.setFocusPolicy(Qt.NoFocus) self.lineedit.setFocusPolicy(Qt.ClickFocus) self.lineedit.setText(text) self.lineedit.installEventFilter(self) self.layout.addWidget(self.checkbox) self.layout.addWidget(self.lineedit) self.setLayout(self.layout) self.checkbox.stateChanged.connect(self.checked_slot) self.lineedit.returnPressed.connect(self.return_slot) def checked_slot(self): self.item_finished_signal.emit(self.index) self.deleteLater() def return_slot(self): if self.lineedit.text(): self.item_commit_signal.emit(self.index) def eventFilter(self, obj, event): if obj == self.lineedit: if event.type() == QEvent.KeyPress: if event.key() == Qt.Key_Tab: self.item_tab_pressed_signal.emit(self.index) return True return QWidget.eventFilter(self, obj, event)
def __init__(self, index, level=0, text=None): super().__init__() self.index = index self.level = level self.layout = QHBoxLayout() self.checkbox = QCheckBox() self.lineedit = QLineEdit() self.checkbox.setFocusPolicy(Qt.NoFocus) self.lineedit.setFocusPolicy(Qt.ClickFocus) self.lineedit.setText(text) self.lineedit.installEventFilter(self) self.layout.addWidget(self.checkbox) self.layout.addWidget(self.lineedit) self.setLayout(self.layout) self.checkbox.stateChanged.connect(self.checked_slot) self.lineedit.returnPressed.connect(self.return_slot)
def _on_check_world(c: QtWidgets.QCheckBox, _): if not self.during_batch_check_update: world_list = self.game_description.world_list w = world_list.world_with_name(c.world_name) world_areas = [ identifier for a in w.areas if c.is_dark_world == a.in_dark_aether if (identifier := world_list.identifier_for_area(a) ) in checks_for_area ] on_check(world_areas, c.isChecked())
def createEditor(self, parent, option, index): if index.column() != 2: return None original_value = index.model().data(index, Qt.UserRole) if not self.is_supported_type(original_value): return None editor = None if isinstance(original_value, bool): editor = QCheckBox(parent) if isinstance(original_value, int): editor = QSpinBox(parent) editor.setRange(-32767, 32767) else: editor = QLineEdit(parent) editor.setFrame(False) validator = self._type_checker.create_validator(original_value, editor) if validator: editor.setValidator(validator) return editor
def change_settings(self, settings): # First clean up all previous items for i in range(self.layout.count()): self.layout.removeItem(self.layout.takeAt(0)) for w in self.widgets: w.deleteLater() self.widgets = [] if not settings: label = QLabel(self.parentWidget()) label.setObjectName("settings_empty_label") label.setText("Для данной операции настройки отсутствуют") label.setWordWrap(True) self.widgets.append(label) self.layout.addWidget(label, 0, 0) else: x = 0 for s in settings: if isinstance(s.type, range): label = QLabel(self.parentWidget()) label.setText(s.text) label.setWordWrap(True) self.widgets.append(label) self.layout.addWidget(label, x, 0) slider = QSlider(self.parentWidget()) slider.setOrientation(Qt.Horizontal) slider.setMinimum(s.type.start // s.type.step) slider.setMaximum(s.type.stop // s.type.step - 1) slider.setValue(s.value // s.type.step) self.layout.addWidget(slider, x + 1, 0) line_edit = QLineEdit(self.parentWidget()) line_edit.setText(str(s.value)) self.layout.addWidget(line_edit, x + 1, 1) slider.valueChanged.connect( partial(self.slider_change, line_edit, s)) line_edit.returnPressed.connect( partial(self.line_edit_change, slider, line_edit, s)) self.widgets.append(slider) self.widgets.append(line_edit) x += 2 elif s.type == bool: checkbox = QCheckBox(self.parentWidget()) checkbox.setText('\n'.join(wrap(s.text, 40))) checkbox.setChecked(s.value) checkbox.clicked.connect( partial(self.checkbox_changed, checkbox, s)) self.layout.addWidget(checkbox, x, 0) self.widgets.append(checkbox) x += 1 elif s.type in (int, float, str): pass
class FindToolBar(QToolBar): find = QtCore.Signal(str, QWebEnginePage.FindFlags) def __init__(self): super(FindToolBar, self).__init__() self._line_edit = QLineEdit() self._line_edit.setClearButtonEnabled(True) self._line_edit.setPlaceholderText("Find...") self._line_edit.setMaximumWidth(300) self._line_edit.returnPressed.connect(self._find_next) self.addWidget(self._line_edit) self._previous_button = QToolButton() style_icons = ':/qt-project.org/styles/commonstyle/images/' self._previous_button.setIcon(QIcon(style_icons + 'up-32.png')) self._previous_button.clicked.connect(self._find_previous) self.addWidget(self._previous_button) self._next_button = QToolButton() self._next_button.setIcon(QIcon(style_icons + 'down-32.png')) self._next_button.clicked.connect(self._find_next) self.addWidget(self._next_button) self._case_sensitive_checkbox = QCheckBox('Case Sensitive') self.addWidget(self._case_sensitive_checkbox) self._hideButton = QToolButton() self._hideButton.setShortcut(QKeySequence(Qt.Key_Escape)) self._hideButton.setIcon(QIcon(style_icons + 'closedock-16.png')) self._hideButton.clicked.connect(self.hide) self.addWidget(self._hideButton) def focus_find(self): self._line_edit.setFocus() def _emit_find(self, backward): needle = self._line_edit.text().strip() if needle: flags = QWebEnginePage.FindFlags() if self._case_sensitive_checkbox.isChecked(): flags |= QWebEnginePage.FindCaseSensitively if backward: flags |= QWebEnginePage.FindBackward self.find.emit(needle, flags) def _find_next(self): self._emit_find(False) def _find_previous(self): self._emit_find(True)
def __init__(self): super().__init__() self.setupUi(self) common_qt_lib.set_default_window_icon(self) self.refresh_button = QPushButton("Refresh") self.button_box.addButton(self.refresh_button, QDialogButtonBox.ResetRole) self.button_box.button(QDialogButtonBox.Ok).setEnabled(False) self.button_box.button(QDialogButtonBox.Ok).setText("Import") self.button_box.accepted.connect(self.attempt_join) self.button_box.rejected.connect(self.reject) self.refresh_button.clicked.connect(self.refresh) self._status_checks = ( (self.status_open_check, "open"), (self.status_invitational_check, "invitational"), (self.status_pending_check, "pending"), (self.status_inprogress_check, "in_progress"), (self.status_finished_check, "finished"), (self.status_cancelled_check, "cancelled"), ) for check, _ in self._status_checks: check.stateChanged.connect(self.update_list) self.filter_name_edit.textEdited.connect(self.update_list) self._game_checks = set() for game in _SUPPORTED_GAME_URLS: game_checkbox = QCheckBox(game.long_name) game_checkbox.setChecked(True) self.game_check_layout.addWidget(game_checkbox) game_checkbox.stateChanged.connect(self.update_list) self._game_checks.add((game_checkbox, game)) self.table_widget.itemSelectionChanged.connect( self.on_selection_changed) self.table_widget.itemDoubleClicked.connect(self.on_double_click)