Beispiel #1
0
    def createEditor(self, parent, option, index):
        """Override.

        instanciate the editor widget and initialize it
        also connect currentIndexChanged signal.
        """
        cb = widgets.CheckBox(parent)
        cb.currentIndexChanged.connect(self.currentIndexChanged)
        return cb
Beispiel #2
0
 def __init__(self, label, value=None, check=True, use_push=False):
     super().__init__(label, value=value, check=check)
     if use_push:
         self.widget = widgets.PushButton()
         self.widget.setCheckable(True)
     else:
         self.widget = widgets.CheckBox()
     if value is not None:
         self.widget.set_value(value)
Beispiel #3
0
def test_checkbox():
    widget = widgets.CheckBox()
    widget.set_disabled()
    widget.set_enabled()
    import pickle
    with open("data.pkl", "wb") as jar:
        pickle.dump(widget, jar)
    with open("data.pkl", "rb") as jar:
        widget = pickle.load(jar)
    assert bool(widget) is False
    widget.set_value(True)
    assert widget.get_value() is True
    repr(widget)
Beispiel #4
0
def test_checkbox():
    widget = widgets.CheckBox()
    widget.set_disabled()
    widget.set_enabled()
    import pickle
    with open("data.pkl", "wb") as jar:
        pickle.dump(widget, jar)
    with open("data.pkl", "rb") as jar:
        widget = pickle.load(jar)
    assert bool(widget) is False
    widget.set_value(True)
    assert widget.get_value() is True
    repr(widget)
    with pytest.raises(ValueError):
        widget.set_checkstate("test")
    widget.is_on = False
    assert widget.is_on is False
Beispiel #5
0
 def __init__(
     self,
     title: str = "Regex Editor",
     regex: str = "",
     teststring: str = "",
     parent: QtWidgets.QWidget | None = None,
 ):
     super().__init__(parent)
     self.resize(1200, 800)
     self.set_title(title)
     self.set_icon("mdi.regex")
     self.set_layout("horizontal")
     self.left_layout = widgets.BoxLayout("vertical")
     self.right_layout = widgets.BoxLayout("vertical")
     self.prog: Pattern | None = None
     self.matches: list[Match] = list()
     self.groupbox = widgets.GroupBox(title="Regular expression")
     self.grid = widgets.GridLayout(self.groupbox)
     self.layout_toprow = widgets.BoxLayout("horizontal")
     self.regexinput = custom_widgets.RegexInput()
     self.regexinput.set_min_size(400, 0)
     self.layout_toprow.add(self.regexinput)
     self.grid.add(self.layout_toprow, 1, 0)
     self.left_layout.add(self.groupbox)
     self.groupbox_teststring = widgets.GroupBox(title="Test strings")
     self.groupbox_teststring.set_layout("grid")
     self.textedit_teststring = widgets.PlainTextEdit(teststring)
     self.textedit_teststring.set_min_size(400, 0)
     self.groupbox_teststring.box.add(self.textedit_teststring, 0, 0)
     self.label_num_matches = widgets.Label("No match")
     self.label_num_matches.set_alignment("center")
     self.left_layout.add(self.groupbox_teststring)
     self.groupbox_sub = widgets.GroupBox(title="Substitution", checkable=True)
     self.layout_sub = widgets.GridLayout(self.groupbox_sub)
     self.lineedit_sub = widgets.LineEdit()
     self.lineedit_sub.textChanged.connect(self.update_sub_textedit)
     self.textedit_sub = widgets.PlainTextEdit()
     self.textedit_sub.set_min_size(400, 0)
     self.textedit_sub.set_read_only()
     self.layout_sub.add(self.lineedit_sub, 0, 0)
     self.layout_sub.add(self.textedit_sub, 1, 0)
     self.left_layout.add(self.groupbox_sub)
     self.cb_quickref = widgets.CheckBox("Show Regular Expression Quick Reference")
     self.left_layout.add(self.cb_quickref)
     self.table_matches = widgets.TableView()
     self.table_matches.setup_list_style()
     self.box.add(self.left_layout)
     self.box.add(self.right_layout)
     self.right_layout.add(self.label_num_matches)
     self.right_layout.add(self.table_matches)
     model = custom_models.RegexMatchesModel()
     self.table_matches.set_model(model)
     self.table_matches.setColumnWidth(0, 60)
     self.table_matches.setColumnWidth(1, 60)
     self.groupbox_sub.toggled.connect(self.lineedit_sub.setVisible)
     self.groupbox_sub.toggled.connect(self.textedit_sub.setVisible)
     doc = self.textedit_teststring.document()
     self._highlighter = RegexMatchHighlighter(doc)
     self._highlighter.rehighlight()
     self.cb_quickref.stateChanged.connect(self.quick_ref_requested)
     self.regexinput.value_changed.connect(self._update_view)
     self.textedit_teststring.textChanged.connect(self._update_view)
     self.regexinput.pattern = regex
     self._update_view()
Beispiel #6
0
 def add(self, title: str, flag: int):
     checkbox = widgets.CheckBox(title)
     checkbox.toggled.connect(self.update_choice)
     self.buttons[checkbox] = flag
     self.box.add(checkbox)
Beispiel #7
0
def test_checkbox():
    chk = widgets.CheckBox()
    chk.show()
    chk.close()