コード例 #1
0
ファイル: widget.py プロジェクト: phil65/PrettyQt
    def set_layout(
        self,
        layout: LayoutStr | QtWidgets.QLayout | None,
        margin: int | None = None,
        spacing: int | None = None,
    ):
        if layout is None:
            return
        if layout == "horizontal":
            self.box = widgets.BoxLayout("horizontal")
        elif layout == "vertical":
            self.box = widgets.BoxLayout("vertical")
        elif layout == "grid":
            self.box = widgets.GridLayout()
        elif layout == "form":
            self.box = widgets.FormLayout()
        elif layout == "stacked":
            self.box = widgets.StackedLayout()
        elif layout == "flow":
            from prettyqt import custom_widgets

            self.box = custom_widgets.FlowLayout()
        elif isinstance(layout, QtWidgets.QLayout):
            self.box = layout
        else:
            raise ValueError("Invalid Layout")
        self.setLayout(self.box)
        if margin is not None:
            self.box.set_margin(margin)
        if spacing is not None:
            self.box.setSpacing(spacing)
コード例 #2
0
ファイル: widget.py プロジェクト: msduketown/PrettyQt
 def set_layout(self, layout):
     if layout in ["horizontal", "vertical"]:
         self.box = widgets.BoxLayout(layout)
     elif layout == "grid":
         self.box = widgets.GridLayout()
     elif layout == "form":
         self.box = widgets.FormLayout()
     elif layout == "stacked":
         self.box = widgets.StackedLayout()
     elif layout == "flow":
         from prettyqt import custom_widgets
         self.box = custom_widgets.FlowLayout()
     else:
         self.box = layout
     if self.box is not None:
         self.setLayout(self.box)
コード例 #3
0
ファイル: test_widgets.py プロジェクト: timfl94/PrettyQt
def test_formlayout():
    widget = widgets.FormLayout()
    widget.set_size_mode("maximum")
    with pytest.raises(ValueError):
        widget.set_size_mode("bla")
    widget[0, "left"] = "0, left"
    widget[1, "left"] = widgets.RadioButton("1, left")
    widget[0, "right"] = "label 1 right"
    widget[1, "right"] = widgets.RadioButton("1, right")
    widget[2] = "by str"
    widget[3] = widgets.RadioButton("widget[3]")
    widget += widgets.RadioButton("added with +=")
    widget += ("added with +=", widgets.RadioButton("tuple"))
    widget = widgets.FormLayout.from_dict({"from": "dict"})
    with open("data.pkl", "wb") as jar:
        pickle.dump(widget, jar)
    with open("data.pkl", "rb") as jar:
        widget = pickle.load(jar)
    assert len(widget) == 2
    repr(widget)
コード例 #4
0
def test_formlayout():
    widget = widgets.FormLayout()
    widget.set_size_mode("maximum")
    return True