def __init__(self): super().__init__() self.resize(500, 500) self.web_view = widgets.TextBrowser(self) self.setCentralWidget(self.web_view) # self.web_view.loadFinished.connect(self._load_finished) self.create_menu()
def __init__(self): super().__init__() central_widget = widgets.TextBrowser() central_widget.setPlainText("Central widget") layout = BorderLayout() layout.addWidget(central_widget, BorderLayout.Position.Center) # Because BorderLayout doesn't call its super-class addWidget() it # doesn't take ownership of the widgets until setLayout() is called. # Therefore we keep a local reference to each label to prevent it being # garbage collected too soon. label_n = self.create_label("North") layout.addWidget(label_n, BorderLayout.Position.North) label_w = self.create_label("West") layout.addWidget(label_w, BorderLayout.Position.West) label_e1 = self.create_label("East 1") layout.addWidget(label_e1, BorderLayout.Position.East) label_e2 = self.create_label("East 2") layout.addWidget(label_e2, BorderLayout.Position.East) label_s = self.create_label("South") layout.addWidget(label_s, BorderLayout.Position.South) self.setLayout(layout) self.setWindowTitle("Border Layout")
def test_expandableline(qtbot): layout = widgets.BoxLayout("vertical") layout.addWidget(widgets.TextBrowser()) widget = custom_widgets.ExpandableLine("Test") widget.set_layout(layout) widget.show()
def test_textbrowser(): widget = widgets.TextBrowser() with open("data.pkl", "wb") as jar: pickle.dump(widget, jar) with open("data.pkl", "rb") as jar: widget = pickle.load(jar)
# === SIGNALS === # self.expand_btn.toggled.connect(expand_view) self.toggle_anim.set_duration(0) self.toggle_anim.set_duration(self._animation_duration) def set_layout( self, layout: str | QtWidgets.QLayout | None, margin: int | None = None, spacing: int | None = None, ) -> None: self.content_area.destroy() self.content_area.set_layout(layout, margin=margin, spacing=spacing) collapsed_height = self.sizeHint().height() - self.content_area.maximumHeight() content_height = self.content_area.box.sizeHint().height() + 300 for expand_anim in self.toggle_anim[:-1]: # expand_anim.setDuration(self._animation_duration) expand_anim.set_range(collapsed_height, collapsed_height + content_height) content_anim = self.toggle_anim[-1] content_anim.set_range(1, content_height) if __name__ == "__main__": app = widgets.app() layout = widgets.BoxLayout("vertical") layout.addWidget(widgets.TextBrowser()) widget = ExpandableLine("Test") widget.set_layout(layout) widget.show() app.main_loop()
def test_textbrowser(): reader = widgets.TextBrowser() reader.show() reader.close() assert True