Skip to content

IconWidget

Qt Base Class: QLabel

Signature: QLabel(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None QLabel(self, text: str, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None

Base classes

Name Children Inherits
Label
prettyqt.widgets.label

⋔ Inheritance diagram

graph TD
  1473367054048["custom_widgets.IconWidget"]
  1473296213920["widgets.Label"]
  1473293662864["widgets.FrameMixin"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473290630080["QtWidgets.QLabel"]
  1473290626176["QtWidgets.QFrame"]
  1473290849680["QtWidgets.QWidget"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473300082368["QtGui.QPaintDevice"]
  1473296213920 --> 1473367054048
  1473293662864 --> 1473296213920
  1473293688240 --> 1473293662864
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480
  1473290630080 --> 1473296213920
  1473290626176 --> 1473290630080
  1473290849680 --> 1473290626176
  1473288842240 --> 1473290849680
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208
  1473300082368 --> 1473290849680
  1473291690208 --> 1473300082368

🛈 DocStrings

Bases: Label

Source code in prettyqt\custom_widgets\labels\iconwidget.py
class IconWidget(widgets.Label):
    def __init__(self, *names, parent: widgets.QWidget | None = None, **kwargs):
        super().__init__(parent=parent)
        self._icon: gui.QIcon | None = None
        self._size = core.Size(16, 16)
        self.set_icon(iconprovider._icon(*names, **kwargs))

    def set_icon(self, _icon: datatypes.IconType):
        """Set a new icon().

        Parameters
        ----------
        _icon: qtawesome.icon
            icon to set
        """
        self._icon = iconprovider.get_icon(_icon)
        self.setPixmap(self._icon.pixmap(self._size))

    def set_icon_size(self, size: datatypes.SizeType):
        self._size = datatypes.to_size(size)
        self.update()

    def update(self, *args, **kwargs):
        if self._icon:
            self.setPixmap(self._icon.pixmap(self._size))
        return super().update(*args, **kwargs)

set_icon(_icon: datatypes.IconType)

Set a new icon().

Parameters

_icon: qtawesome.icon icon to set

Source code in prettyqt\custom_widgets\labels\iconwidget.py
def set_icon(self, _icon: datatypes.IconType):
    """Set a new icon().

    Parameters
    ----------
    _icon: qtawesome.icon
        icon to set
    """
    self._icon = iconprovider.get_icon(_icon)
    self.setPixmap(self._icon.pixmap(self._size))

⌗ 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
frameShape QFrame::Shape
frameShadow QFrame::Shadow
lineWidth int
midLineWidth int
frameWidth int
frameRect QRect
text QString
textFormat Qt::TextFormat
pixmap QPixmap
scaledContents bool
alignment QFlags
wordWrap bool
margin int
indent int
openExternalLinks bool
textInteractionFlags QFlags
hasSelectedText bool
selectedText QString
elideMode QString Text Elide style