Пример #1
0
    def __init__(
        self,
        title: str = "",
        animation_duration: int = 300,
        parent: QtWidgets.QWidget | None = None,
    ):
        super().__init__(parent=parent)

        self._animation_duration = animation_duration

        self.expand_btn = widgets.ToolButton()
        self.expand_btn.set_text(title)
        with self.expand_btn.edit_stylesheet() as ss:
            ss.QToolButton.border.setValue(None)
        self.expand_btn.set_style("text_beside_icon")
        self.expand_btn.set_arrow_type("right")
        self.expand_btn.setCheckable(True)
        self.expand_btn.setChecked(False)

        header_line = widgets.Frame()
        header_line.set_frame_shape("h_line")
        header_line.set_frame_shadow("sunken")
        header_line.set_size_policy("expanding", "maximum")

        self.content_area = widgets.ScrollArea()
        with self.expand_btn.edit_stylesheet() as ss:
            ss.QAbstractScrollArea.border.setValue(None)
        self.content_area.set_size_policy("expanding", "fixed")
        self.content_area.setMaximumHeight(1)
        # self.content_area.setMinimumHeight(0)

        self.toggle_anim = core.ParallelAnimationGroup()
        self.toggle_anim.add_property_animation(self, "minimumHeight")
        self.toggle_anim.add_property_animation(self, "maximumHeight")
        self.toggle_anim.add_property_animation(self.content_area, "maximumHeight")
        base_layout = widgets.GridLayout()
        base_layout.setVerticalSpacing(0)
        base_layout.set_margin(0)
        base_layout.addWidget(
            self.expand_btn, 0, 0, 1, 1, constants.ALIGN_LEFT
        )  # type: ignore
        base_layout[0, 2] = header_line
        base_layout[1, 0:2] = self.content_area
        self.setLayout(base_layout)
        # self.toggle_anim.setStartValue(0)
        # self.toggle_anim.setEndValue(300)

        def expand_view(checked: bool):
            self.expand_btn.set_arrow_type("down" if checked else "right")
            self.toggle_anim.set_direction("forward" if checked else "backward")
            self.toggle_anim.start()

        # === SIGNALS === #
        self.expand_btn.toggled.connect(expand_view)
        self.toggle_anim.set_duration(0)
        self.toggle_anim.set_duration(self._animation_duration)
Пример #2
0
    def __init__(self):
        super().__init__()
        self.setMinimumSize(400, 300)
        self.set_title("Icon Browser")
        from prettyqt import iconprovider

        iconprovider._instance()
        font_maps = iconprovider._instance().charmap

        icon_names = [
            f"{font_collection}.{icon_name}"
            for font_collection, font_data in font_maps.items()
            for icon_name in font_data
        ]
        self._filter_timer = core.Timer(self)
        self._filter_timer.setSingleShot(True)
        self._filter_timer.setInterval(AUTO_SEARCH_TIMEOUT)
        self._filter_timer.timeout.connect(self._update_filter)

        model = IconModel(self.get_palette().get_color("text"))
        model.setStringList(sorted(icon_names))

        self._proxy_model = core.SortFilterProxyModel()
        self._proxy_model.setSourceModel(model)
        self._proxy_model.set_filter_case_sensitive(True)

        self._listview = IconListView(self)
        self._listview.setUniformItemSizes(True)
        self._listview.set_view_mode("icon")
        self._listview.set_model(self._proxy_model)
        self._listview.set_contextmenu_policy("custom")
        self._listview.doubleClicked.connect(self._copy_icon_text)

        self._lineedit = widgets.LineEdit(parent=self)
        self._lineedit.textChanged.connect(self._filter_timer.restart)
        self._lineedit.returnPressed.connect(self._trigger_instant_update)

        self._combobox = widgets.ComboBox(parent=self)
        self._combobox.setMinimumWidth(75)
        self._combobox.currentIndexChanged.connect(
            self._trigger_instant_update)
        self._combobox.addItems([ALL_COLLECTIONS] + sorted(font_maps.keys()))

        lyt = widgets.BoxLayout("horizontal")
        lyt.set_margin(0)
        lyt.add(self._combobox)
        lyt.add(self._lineedit)

        search_bar_frame = widgets.Frame(self)
        search_bar_frame.setLayout(lyt)

        self._copy_button = widgets.PushButton("Copy Name", self)
        self._copy_button.clicked.connect(self._copy_icon_text)

        lyt = widgets.BoxLayout("vertical")
        lyt.add(search_bar_frame)
        lyt.add(self._listview)
        lyt.add(self._copy_button)
        frame = widgets.Frame(self)
        frame.set_layout(lyt)
        self.setCentralWidget(frame)
        widgets.Shortcut(gui.KeySequence("return"), self, self._copy_icon_text)
        self._lineedit.setFocus()
        self.center()
Пример #3
0
def test_frame():
    widgets.Frame()
Пример #4
0
def test_frame():
    widget = widgets.Frame()
    widget.show()
    widget.close()