Skip to content

IconBrowser

Qt Base Class: QMainWindow

Signature: QMainWindow(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, flags: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None

Base classes

Name Children Inherits
MainWindow
prettyqt.widgets.mainwindow

⋔ Inheritance diagram

graph TD
  1473367116512["custom_widgets.IconBrowser"]
  1473296227584["widgets.MainWindow"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473290635936["QtWidgets.QMainWindow"]
  1473290849680["QtWidgets.QWidget"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473300082368["QtGui.QPaintDevice"]
  1473296227584 --> 1473367116512
  1473293688240 --> 1473296227584
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480
  1473290635936 --> 1473296227584
  1473290849680 --> 1473290635936
  1473288842240 --> 1473290849680
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208
  1473300082368 --> 1473290849680
  1473291690208 --> 1473300082368

🛈 DocStrings

Bases: MainWindow

A small browser window that allows the user to search through all icons.

You can also copy the name and python code for the currently selected icon.

Source code in prettyqt\custom_widgets\iconbrowser.py
class IconBrowser(widgets.MainWindow):
    """A small browser window that allows the user to search through all icons.

    You can also copy the name and python code for the currently selected icon.
    """

    def __init__(self):
        super().__init__()
        self.setMinimumSize(500, 500)
        self.set_title("Icon Browser")
        font_maps = {k: v.charmap for k, v in iconprovider._instance().fonts.items()}
        icon_names = [
            f"{font_collection}.{icon_name}"
            for font_collection, font_data in font_maps.items()
            for icon_name in font_data
        ]
        model = IconModel(icon_color="text_role")
        model.setStringList(sorted(icon_names))

        self._proxy_model = itemmodels.FuzzyFilterProxyModel()
        self._proxy_model.setSourceModel(model)
        self._proxy_model.set_filter_case_sensitive(True)
        self._proxy_model.set_match_color(None)

        self._listview = widgets.ListView(
            self,
            uniform_item_sizes=True,
            view_mode="icon",
            context_menu_policy="custom",
            double_clicked=self._copy_icon_text,
            vertical_scroll_bar_policy="always_on",
        )
        eventfilter = listviewgridresizeeventfilter.ListViewGridResizeEventFilter(
            parent=self._listview
        )
        self._listview.installEventFilter(eventfilter)
        self._listview.set_model(self._proxy_model)

        self._lineedit = widgets.LineEdit(
            parent=self, text_changed=self._trigger_instant_update
        )

        self._combobox = widgets.ComboBox(
            parent=self,
            minimum_width=75,
            current_index_changed=self._trigger_instant_update,
        )
        self._combobox.addItems([ALL_COLLECTIONS, *sorted(font_maps.keys())])

        search_bar_frame = widgets.Frame(self)
        layout = search_bar_frame.set_layout("horizontal", margin=0)
        layout.add(self._combobox)
        layout.add(self._lineedit)

        self._copy_button = widgets.PushButton("Copy Name", clicked=self._copy_icon_text)
        frame = widgets.Frame(self)
        layout = frame.set_layout("vertical")
        layout.add(search_bar_frame)
        layout.add(self._listview)
        layout.add(self._copy_button)
        self.setCentralWidget(frame)
        self.add_shortcut("return", callback=self._copy_icon_text)
        self._lineedit.setFocus()
        self.position_on("screen")

    def _trigger_instant_update(self):
        """Stop timer used for committing search term and update proxy model instantly."""
        self._proxy_model.set_search_term(self._lineedit.text())

    def _copy_icon_text(self):
        """Copy the name of the currently selected icon to the clipboard."""
        if indexes := self._listview.selectedIndexes():
            widgets.Application.copy_to_clipboard(indexes[0].data())

⌗ Property table

Qt Property Type Doc
objectName QString
modal bool
windowModality Qt::WindowModality
enabled bool
geometry QRect
frameGeometry QRect
normalGeometry QRect
x int
y int
pos QPoint
frameSize QSize
size QSize
width int
height int
rect QRect
childrenRect QRect
childrenRegion QRegion
sizePolicy QSizePolicy
minimumSize QSize
maximumSize QSize
minimumWidth int
minimumHeight int
maximumWidth int
maximumHeight int
sizeIncrement QSize
baseSize QSize
palette QPalette
font QFont
cursor QCursor
mouseTracking bool
tabletTracking bool
isActiveWindow bool
focusPolicy Qt::FocusPolicy
focus bool
contextMenuPolicy Qt::ContextMenuPolicy
updatesEnabled bool
visible bool
minimized bool
maximized bool
fullScreen bool
sizeHint QSize
minimumSizeHint QSize
acceptDrops bool
windowTitle QString
windowIcon QIcon
windowIconText QString
windowOpacity double
windowModified bool
toolTip QString
toolTipDuration int
statusTip QString
whatsThis QString
accessibleName QString
accessibleDescription QString
layoutDirection Qt::LayoutDirection
autoFillBackground bool
styleSheet QString
locale QLocale
windowFilePath QString
inputMethodHints QFlags
iconSize QSize
toolButtonStyle Qt::ToolButtonStyle
animated bool
documentMode bool
tabShape QTabWidget::TabShape
dockNestingEnabled bool
dockOptions QFlags
unifiedTitleAndToolBarOnMac bool