def on_btns_toggled(self, idx, checked): if checked: if not self._csw_switch.select(idx): with qtx.BlockSignals(self._btns[idx]): self._btns[idx].setChecked(False) else: if not self._csw_switch.unselect(): with qtx.BlockSignals(self._btns[idx]): self._btns[idx].setChecked(True)
def _on_csw_switch_selected(self, idx, choice): with qtx.BlockSignals(self._combobox): if idx is None: self._combobox.setCurrentIndex(0) else: if self._has_none_choice: idx += 1 self._combobox.setCurrentIndex(idx)
def _on_csw_paths(self, paths, prev_paths): if len(paths) == 0: text = None elif len(paths) == 1: text = str(paths[0]) else: raise NotImplementedError() with qtx.BlockSignals(self._lineedit): self._lineedit.setText(text)
def _on_csw_idx_count(self, idx_count): #print('_on_csw_idx_count', idx_count) if idx_count is not None: with qtx.BlockSignals( [self._slider, self._spinbox_index, self._spinbox_count]): self._slider.setMinimum(1) self._slider.setMaximum(idx_count) self._spinbox_index.setMinimum(1) self._spinbox_index.setMaximum(idx_count) self._spinbox_count.setMaximum(idx_count) self._spinbox_count.setValue(idx_count)
def _on_csw_choices(self, choices, choices_names, none_choice_name: Union[str, None]): idx = 0 if self._combobox is not None: idx = self._combobox.currentIndex() self._main_l.removeWidget(self._combobox) self._combobox.deleteLater() self._choices_names = choices_names self._has_none_choice = none_choice_name is not None combobox = self._combobox = qtx.QXComboBox( font=QXFontDB.get_fixedwidth_font(), on_index_changed=self.on_combobox_index_changed) with qtx.BlockSignals(self._combobox): if none_choice_name is not None: combobox.addItem(qtx.QIcon(), L(none_choice_name)) for choice_name in choices_names: combobox.addItem(qtx.QIcon(), L(choice_name)) combobox.setCurrentIndex(idx) self._main_l.addWidget(combobox)
def _on_csw_progress(self, progress): with qtx.BlockSignals(self._progressbar): self._progressbar.setValue(progress)
def _on_csw_idx(self, idx): #print('_on_csw_idx', idx) if idx is not None: with qtx.BlockSignals([self._slider, self._spinbox_index]): self._slider.setValue(idx + 1) self._spinbox_index.setValue(idx + 1)
def _on_csw_number(self, value): if value is not None: config = self._config value = (value - config.min) / config.step with qtx.BlockSignals([self._slider]): self._slider.setValue(value)
def _on_csw_text(self, text): with qtx.BlockSignals(self._lineedit): self._lineedit.setText(text)
def on_csw_flag(self, flag): with qtx.BlockSignals(self._chbox): self._chbox.setChecked(flag)
def _on_csw_number(self, number): with qtx.BlockSignals(self._spinbox): self._spinbox.setValue(number) self._btn_auto_update()
def _on_csw_switch_selected(self, idx, choice): with qtx.BlockSignals(self._btns): for i, btn in enumerate(self._btns): btn.setChecked(i == idx)