Skip to content

SystemTrayIcon

Base classes

Name Children Inherits
ObjectMixin
prettyqt.core.object
QSystemTrayIcon
PySide6.QtWidgets
QSystemTrayIcon(self, icon: PySide6.QtGui.QIcon | PySide6.QtGui.QPixmap, /, parent: PySide6.QtCore.QObject | None \= None, *, toolTip: str | None \= None, visible: bool | None \= None) -> None

⋔ Inheritance diagram

graph TD
  1433178119["widgets.SystemTrayIcon"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  3155999906["QtWidgets.QSystemTrayIcon"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  3227531497 --> 1433178119
  2751680898 --> 3227531497
  3155999906 --> 1433178119
  3984060476 --> 3155999906
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 DocStrings

Bases: ObjectMixin, QSystemTrayIcon

Icon for an application in the system tray.

Source code in prettyqt/widgets/systemtrayicon.py
class SystemTrayIcon(core.ObjectMixin, QtWidgets.QSystemTrayIcon):
    """Icon for an application in the system tray."""

    def set_icon(self, icon: datatypes.IconType):
        """Set the system tray icon.

        Args:
            icon: icon to use
        """
        icon = iconprovider.get_icon(icon)
        self.setIcon(icon)

    def show_message(
        self,
        title: str,
        message: str = "",
        icon: datatypes.IconType = None,
        timeout: int = 10,
    ):
        if icon is None:
            ico = gui.Icon()
        if icon in MESSAGE_ICONS:
            ico = MESSAGE_ICONS[icon]
        else:
            ico = iconprovider.get_icon(icon)
        self.showMessage(title, message, ico, timeout * 1000)

set_icon(icon: datatypes.IconType)

Set the system tray icon.

Parameters:

Name Type Description Default
icon IconType

icon to use

required
Source code in prettyqt/widgets/systemtrayicon.py
def set_icon(self, icon: datatypes.IconType):
    """Set the system tray icon.

    Args:
        icon: icon to use
    """
    icon = iconprovider.get_icon(icon)
    self.setIcon(icon)

:fa-brands-github: Show source on GitHub