def get_float( cls, title: str = "", label: str = "", icon: types.IconType = None, ) -> float | None: par = widgets.Dialog() par.set_icon(icon) v = cls.getDouble(par, title, label, value=0.0) return v[0] if v[1] else None
def get_item( cls, items: list[str], title: str = "", label: str = "", icon: types.IconType = None, editable: bool = False, ) -> str | None: par = widgets.Dialog() par.set_icon(icon) v = cls.getItem(par, title, label, items, editable=editable, current=0) return v[0] if v[1] else None
def test_dialog(qtbot): dlg = widgets.Dialog(layout="horizontal") qtbot.addWidget(dlg) qtbot.keyPress(dlg, QtCore.Qt.Key_F11) dlg.delete_on_close() dlg.add_widget(widgets.RadioButton("test")) dlg.set_icon("mdi.timer") with open("data.pkl", "wb") as jar: pickle.dump(dlg, jar) with open("data.pkl", "rb") as jar: dlg = pickle.load(jar) dlg.resize(0, 400) dlg.resize((0, 400)) dlg.add_buttonbox()
def get_text( cls, title: str = "", label: str = "", icon: types.IconType = None, default_value: str = "", echo_mode: widgets.lineedit.EchoModeStr = "normal", ) -> str | None: par = widgets.Dialog() par.set_icon(icon) if echo_mode not in widgets.lineedit.ECHO_MODE: raise InvalidParamError(echo_mode, widgets.lineedit.ECHO_MODE) v = cls.getText(par, title, label, widgets.lineedit.ECHO_MODE[echo_mode], default_value) return v[0] if v[1] else None
def create_dialog(self): dialog = widgets.Dialog() dialog.set_modality("application") dialog.setMinimumWidth(400) dialog.set_title(self.dialog_title) dialog.set_icon(self.dialog_icon) dialog.set_layout("grid") dialog.box.set_spacing(10) dialog.box.set_margin(20) button_box = widgets.DialogButtonBox() ok_btn = button_box.add_default_button("ok", callback=dialog.accept) button_box.add_default_button("cancel", callback=dialog.reject) widget_dict = {k: v.create_widget() for k, v in self._items.items()} widget_dict = {k: v for k, v in widget_dict.items() if v is not None} def on_update(): is_valid = all(i.is_valid() if hasattr(i, "is_valid") else True for i in widget_dict.values()) ok_btn.setEnabled(is_valid) for i, (k, item) in enumerate(self._items.items()): if k not in widget_dict: continue dialog.box[i, item.label_col] = widgets.Label(item.label) dialog.box[i, item.label_col + 1:item.label_col + 3] = widget_dict[k] widget = widget_dict[k] widget.set_id(k) widget.value_changed.connect(on_update) for active in item.enabled_on: widget.setEnabled(widget_dict[active].get_value()) widget_dict[active].value_changed.connect(widget.setEnabled) for active in item.disabled_on: widget.setDisabled(widget_dict[active].get_value()) widget_dict[active].value_changed.connect(widget.setDisabled) if self.dialog_comment: label = widgets.Label(self.dialog_comment) label.setWordWrap(True) dialog.box[len(self._items) + 1, 0:3] = label dialog.box.append(button_box) on_update() return dialog
def get_item(cls, items, title=None, label=None, icon=None): par = widgets.Dialog() par.set_icon(icon) v = cls.getItem(par, title, label, items, editable=False) if v[1]: return v[0]
def get_text(cls, title=None, label=None, icon=None, default_value=""): par = widgets.Dialog() par.set_icon(icon) v = cls.getText(par, title, label, text=default_value) if v[1]: return v[0]
def get_float(cls, title=None, label=None, icon=None): par = widgets.Dialog() par.set_icon(icon) v = cls.getDouble(par, title, label) if v[1]: return v[0]
return str(len(item.groups())) if role in [constants.USER_ROLE]: return item.span() def rowCount(self, parent=None): """Required override for AbstractitemModels.""" return len(self.matches) if __name__ == "__main__": import re app = widgets.Application([]) view = widgets.TableView() teststring = "fjdjkslfj355fjdkj 55 55454" regex = r"(?:[0-9])*.([0-9])" teststring = "SH_6208069141055_BC000388_20110412101855" regex = r"(?:([a-z]{2,})_)?(\d+)_([a-z]{2,}\d+)_(\d+)$" compiled = re.compile(regex, re.IGNORECASE) matches = list(compiled.finditer(teststring)) model = RegexMatchesModel(matches) view.set_model(model) dlg = widgets.Dialog(layout="horizontal") dlg.add_widget(view) dlg.show_blocking() view.resize(500, 300) print(view.model()) print(view.model().rowCount()) app.main_loop()
def test_dialog(): dlg = widgets.Dialog() dlg.show() dlg.close()