def init_ui(self, wrap=None): super().init_ui() layout = QHBoxLayout() with self.setup_provided(layout): self.spin = QSpinBox() self.spin.valueChanged[int].connect(self.change_value) minimum = 0 maximum = len(self.options) - 1 if wrap: minimum -= 1 maximum += 1 self.spin.valueChanged[int].connect(self.check_wrap) self.spin.setMinimum(minimum) self.spin.setMaximum(maximum) self.spin.valueFromText = self._value_from_text self.spin.textFromValue = self._text_from_value self.spin.validate = self._validate layout.addWidget(self.spin) self.setFocusProxy(self.spin) self.setLayout(layout) return layout
def init_ui(self): super().init_ui() layout = QHBoxLayout(self) with self.setup_provided(layout): self.label = QLabel(self.options[0][0][0]) layout.addWidget(self.label) self.setFocusProxy(self.label) return layout
def init_ui(self): super().init_ui() layout = QHBoxLayout(self) with self.setup_provided(layout): self.checkbox = QCheckBox() self.checkbox.toggled.connect(self.change_value) layout.addWidget(self.checkbox) self.setFocusProxy(self.checkbox) return layout
def inner_layout(self): ret = QHBoxLayout() ret.addWidget(link_to('eval("', "https://docs.python.org/3/library/functions.html#eval")) ret.addWidget(self.edit) ret.addWidget(QLabel('", {"value":value})')) return ret
def init_ui(self): super().init_ui() layout = QHBoxLayout(self) with self.setup_provided(layout): self.combo_box = QComboBox() layout.addWidget(self.combo_box) for names, value in self.options: name = names[0] self.combo_box.addItem(name, value) self.combo_box.currentIndexChanged.connect(self.change_value) self.setFocusProxy(self.combo_box) return layout
def init_ui(self, placeholder=None, edit_cls=None): super().init_ui() layout = QHBoxLayout(self) with self.setup_provided(layout): edit_cls = first_valid(edit_cls=edit_cls, EDIT_CLS=self.EDIT_CLS, _self=self) self.edit = edit_cls() if placeholder: self.edit.setPlaceholderText(self.title) self.edit.textChanged.connect(self.change_value) layout.addWidget(self.edit) self.setFocusProxy(self.edit) return layout
def init_ui(self, layout_cls=None, ok_text=None, cancel_text=None, modality=None): super().init_ui() layout_cls = first_valid(layout_cls=layout_cls, LAYOUT_CLS=self.LAYOUT_CLS, _self=self) modality = modality or self.WINDOW_MODALITY layout: QBoxLayout = layout_cls(self) self.inner = self.inner_template() with self.setup_provided(layout): self.inner.on_change.connect(self._inner_changed) layout.addWidget(self.inner) btn_layout = QHBoxLayout() if self.make_cancel: self.cancel_button = QPushButton(first_valid(cancel_text=cancel_text, CANCEL_TEXT=self.CANCEL_TEXT, _self=self)) self.cancel_button.clicked.connect(self._cancel_btn_clicked) btn_layout.addWidget(self.cancel_button) self.ok_button = QPushButton(first_valid(ok_text=ok_text, CANCEL_TEXT=self.OK_TEXT, _self=self)) self.ok_button.clicked.connect(self._ok_btn_clicked) btn_layout.addWidget(self.ok_button) layout.addLayout(btn_layout) self.setFocusProxy(self.inner) if modality: self.setWindowModality(modality) #if not self.make_cancel: #self.setWindowFlags(Qt.WindowMinimizeButtonHint) self.add_plaintext_delegates(self.inner) return layout
def init_ui(self, minimum=None, maximum=None, step=None, use_float=None, prefix=None, suffix=None, decimals=None, initial_value=None): super().init_ui() layout = QHBoxLayout() with self.setup_provided(layout): spin_cls = QDoubleSpinBox if use_float else QSpinBox self.spin = spin_cls() self.spin.valueChanged[int].connect(self.change_value) if minimum: self.spin.setMinimum(minimum) if maximum: self.spin.setMaximum(maximum) if step: self.spin.setSingleStep(step) if prefix: self.spin.setPrefix(prefix) if suffix: self.spin.setSuffix(suffix) if decimals: self.spin.setDecimals(decimals) layout.addWidget(self.spin) if use_float: self.add_plaintext_delegates(FidgetFloat) else: self.add_plaintext_delegates(FidgetInt) initial_value = optional_valid(initial_value=initial_value, INITIAL_VALUE=self.INITIAL_VALUE, _self=self) if initial_value: self.spin.setValue(initial_value) self.setFocusProxy(self.spin) self.setLayout(layout) return layout
def setup_ui(self): master_layout = QHBoxLayout() self.tree = QTreeWidget() self.tree.setHeaderLabels(['item', '# of episodes', 'location']) master_layout.addWidget(self.tree) button_set = QVBoxLayout() save_btn = QToolButton() save_btn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) save_action = QAction('save') save_btn.setDefaultAction(save_action) save_menu = QMenu(parent=self) save_as_action = save_menu.addAction('save as') def save_project(proj: CerialProject, path: Path): with path.open('w') as w: proj.dump(w) proj.path = path def save_as(*a): filename, _ = QFileDialog.getSaveFileName( self, 'save as', filter='cerial project (*.cerl);; all files (*.*)') if not filename: return path = Path(filename) save_project(self.project, path) save_as_action.triggered.connect(save_as) @save_action.triggered.connect def save(*a): if self.project.path is None: save_as(*a) else: save_project(self.project, self.project.path) save_btn.setMenu(save_menu) save_btn.setPopupMode(QToolButton.MenuButtonPopup) add_btn = QPushButton('add episodes') add_btn.clicked.connect(self.show_add_dialog) play_btn = QPushButton('play...') stats_btn = QPushButton('statistics') button_set.addWidget(save_btn) button_set.addWidget(add_btn) button_set.addWidget(play_btn) button_set.addWidget(stats_btn) master_layout.addLayout(button_set) self.setLayout(master_layout) self.add_dialog = FidgetQuestion(AddEpisodes('add episodes'), cancel_value=None)
def init_ui(self): super().init_ui() layout = QHBoxLayout(self) with self.setup_provided(layout): self.combo_box = QComboBox() self.combo_box.setEditable(True) layout.addWidget(self.combo_box) self._opt_lookup_name = {} for value in self.options: names, value = parse_option(self, value) name = names[0] self.combo_box.addItem(name, value) for n in names: self._opt_lookup_name[n] = value self.combo_box.editTextChanged.connect(self.change_value) self.setFocusProxy(self.combo_box) return layout
def init_ui(self): layout = QHBoxLayout() self.stacked = QStackedWidget() self.make_project = MakeProjectWidget() @self.make_project.on_change.connect def make_project_changed(): v = self.make_project.value() if not v.is_ok(): QMessageBox.critical(self, 'error', v.details) else: self.switch_to_overview(v.value) self.stacked.addWidget(self.make_project) self.overview = OverviewWidget() self.stacked.addWidget(self.overview) layout.addWidget(self.stacked) self.setLayout(layout)
def init_ui(self): master_layout = QVBoxLayout() inner_layout = self.inner_layout() master_layout.addLayout(inner_layout) btn_layout = QHBoxLayout() btn_layout.addWidget(self.cancel_btn) btn_layout.addWidget(self.ok_btn) master_layout.addLayout(btn_layout) self.setLayout(master_layout) self.setWindowTitle(self.TITLE)
def init_ui(self): super().init_ui() layout = QHBoxLayout() with self.setup_provided(layout): self.x_edit = QLineEdit() self.x_edit.setPlaceholderText('X') self.x_edit.textChanged.connect(self.change_value) layout.addWidget(self.x_edit) self.y_edit = QLineEdit() self.y_edit.setPlaceholderText('Y') self.y_edit.textChanged.connect(self.change_value) layout.addWidget(self.y_edit) self.setLayout(layout)
def init_ui(self, dialog=None): super().init_ui() self.dialog = self._args_to_filedialog( first_valid(dialog=dialog, DIALOG=self.DIALOG, _self=self)) layout = QHBoxLayout(self) with self.setup_provided(layout): self.edit = QLineEdit() self.edit.textChanged.connect(self.change_value) layout.addWidget(self.edit) browse_btn = QPushButton('...') browse_btn.pressed.connect(self.browse) layout.addWidget(browse_btn) self.setFocusProxy(self.edit) return layout
def inner_layout(self): ret = QHBoxLayout() self.combo_box = QFontComboBox() self.combo_box.setCurrentIndex(-1) self.combo_box.currentTextChanged.connect(self._update_preview) ret.addWidget(self.combo_box) self.size_edit = QSpinBox() self.size_edit.setValue(8) self.size_edit.setRange(6, 50) self.size_edit.valueChanged[int].connect(self._update_preview) ret.addWidget(self.size_edit) self.preview_label = QLabel('preview\n1234567') ret.addWidget(self.preview_label) self.default_btn = QPushButton('default') @self.default_btn.clicked.connect def fill_default(a): self.fill(QFontDatabase.systemFont(QFontDatabase.GeneralFont)) ret.addWidget(self.default_btn) self.monospace_btn = QPushButton('monospace') @self.monospace_btn.clicked.connect def fill_mono(a): self.fill(QFontDatabase.systemFont(QFontDatabase.FixedFont)) ret.addWidget(self.monospace_btn) return ret
def init_ui(self) -> Optional[QBoxLayout]: super().init_ui() self.setWindowModality(Qt.WindowModal) master_layout = QVBoxLayout(self) self.print_widget = QGroupBox('current value:') print_master_layout = QVBoxLayout(self.print_widget) print_layout = QHBoxLayout() print_master_layout.addLayout(print_layout) self.print_edit = QPlainTextEdit() self.print_edit.setReadOnly(True) print_layout.addWidget(self.print_edit) print_extras_layout = QGridLayout() self.print_combo = QComboBox() file_button = QPushButton('to file...') file_button.clicked.connect(self.save_file) print_extras_layout.addWidget(file_button, 0, 0) print_extras_layout.addWidget(self.print_combo, 1, 0) print_layout.addLayout(print_extras_layout) master_layout.addWidget(self.print_widget) self.clone_button = QPushButton('🡇') self.clone_button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.clone_button.clicked.connect(self._clone_btn_clicked) master_layout.addWidget(self.clone_button) self.parse_widget = QGroupBox('set value:') parse_master_layout = QVBoxLayout(self.parse_widget) parse_layout = QHBoxLayout() parse_master_layout.addLayout(parse_layout) self.parse_edit = self._ShiftEnterIgnoringPlainTextEdit() self.parse_edit.textChanged.connect(self.change_value) self.print_combo.activated.connect(self.update_print) parse_layout.addWidget(self.parse_edit) parse_extras_layout = QGridLayout() self.parse_combo = QComboBox() self.parse_combo.activated.connect(self.change_value) parse_extras_layout.addWidget(self.parse_combo, 0, 0) if self.indicator_label: parse_extras_layout.addWidget(self.indicator_label, 0, 1) file_button = QPushButton('from file...') file_button.clicked.connect(self.load_file) parse_extras_layout.addWidget(file_button, 1, 0, 1, 2) self.apply_button = QPushButton('apply') self.apply_button.clicked.connect(self.apply_parse) parse_extras_layout.addWidget(self.apply_button, 2, 0) self.ok_button = QPushButton('OK') self.ok_button.clicked.connect(self.commit_parse) parse_extras_layout.addWidget(self.ok_button, 2, 1) parse_layout.addLayout(parse_extras_layout) master_layout.addWidget(self.parse_widget) self.font_button = QPushButton('font...') self.font_button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.font_button.clicked.connect(self._choose_font) master_layout.addWidget(self.font_button) self.on_change.connect(self._on_value_change) return master_layout