• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QUndoGroup

    下一话题

    QCompleter

    QSystemTrayIcon

    概要

    函数

    信号

    详细描述

    PySide.QtGui.QSystemTrayIcon class provides an icon for an application in the system tray.

    现代操作系统通常在桌面提供特殊区域,称为 系统托盘 or 通知区域 ,在那里长时间运行应用程序可以显示图标和短消息。

    ../../_images/system-tray.png

    PySide.QtGui.QSystemTrayIcon class can be used on the following platforms:

    • 所有支持的 Windows 版本。
    • All window managers for X11 that implement the freedesktop.org system tray specification, including recent versions of KDE and GNOME.
    • All supported versions of Mac OS X. Note that the Growl notification system must be installed for QSystemTrayIcon.showMessage() to display messages.

    要校验系统托盘是否呈现在用户桌面,调用 QSystemTrayIcon.isSystemTrayAvailable() static function.

    To add a system tray entry, create a PySide.QtGui.QSystemTrayIcon object, call PySide.QtGui.QSystemTrayIcon.setContextMenu() to provide a context menu for the icon, and call PySide.QtGui.QSystemTrayIcon.show() to make it visible in the system tray. Status notification messages (“balloon messages”) can be displayed at any time using PySide.QtGui.QSystemTrayIcon.showMessage() .

    If the system tray is unavailable when a system tray icon is constructed, but becomes available later, PySide.QtGui.QSystemTrayIcon will automatically add an entry for the application in the system tray if the icon is visible() .

    PySide.QtGui.QSystemTrayIcon.activated() signal is emitted when the user activates the icon.

    Only on X11, when a tooltip is requested, the PySide.QtGui.QSystemTrayIcon 接收 PySide.QtGui.QHelpEvent of type QEvent.ToolTip . Additionally, the PySide.QtGui.QSystemTrayIcon receives wheel events of type QEvent.Wheel 。这些不被支持,在任何其它平台。

    另请参阅

    PySide.QtGui.QDesktopServices PySide.QtGui.QDesktopWidget 桌面集成 系统托盘图标范例

    class PySide.QtGui. QSystemTrayIcon ( [ parent=None ] )
    class PySide.QtGui. QSystemTrayIcon ( icon [ , parent=None ] )
    参数:

    构造 PySide.QtGui.QSystemTrayIcon 对象采用给定 parent .

    图标最初是不可见的。

    另请参阅

    visible()

    构造 PySide.QtGui.QSystemTrayIcon 对象采用给定 icon and parent .

    图标最初是不可见的。

    另请参阅

    visible()

    PySide.QtGui.QSystemTrayIcon. MessageIcon

    此枚举描述展示图标,当显示气球消息时。

    常量 描述
    QSystemTrayIcon.NoIcon 没有展示图标。
    QSystemTrayIcon.Information 展示信息图标。
    QSystemTrayIcon.Warning 展示标准警告图标。
    QSystemTrayIcon.Critical 展示严重警告图标。
    PySide.QtGui.QSystemTrayIcon. ActivationReason

    此枚举描述系统托盘被激活的原因。

    常量 描述
    QSystemTrayIcon.Unknown 未知原因
    QSystemTrayIcon.Context 用于系统托盘条目的上下文菜单被请求
    QSystemTrayIcon.DoubleClick The system tray entry was double clicked
    QSystemTrayIcon.Trigger 系统托盘条目被点击
    QSystemTrayIcon.MiddleClick 系统托盘条目被点击,采用鼠标中键
    PySide.QtGui.QSystemTrayIcon. activated ( reason )
    参数: reason PySide.QtGui.QSystemTrayIcon.ActivationReason
    PySide.QtGui.QSystemTrayIcon. contextMenu ( )
    返回类型: PySide.QtGui.QMenu

    Returns the current context menu for the system tray entry.

    PySide.QtGui.QSystemTrayIcon. geometry ( )
    返回类型: PySide.QtCore.QRect

    Returns the geometry of the system tray icon in screen coordinates.

    另请参阅

    visible()

    PySide.QtGui.QSystemTrayIcon. hide ( )

    隐藏系统托盘条目。

    PySide.QtGui.QSystemTrayIcon. icon ( )
    返回类型: PySide.QtGui.QIcon

    This property holds the system tray icon.

    On Windows, the system tray icon size is 16x16; on X11, the preferred size is 22x22. The icon will be scaled to the appropriate size as necessary.

    static PySide.QtGui.QSystemTrayIcon. isSystemTrayAvailable ( )
    返回类型: PySide.QtCore.bool

    Returns true if the system tray is available; otherwise returns false.

    If the system tray is currently unavailable but becomes available later, PySide.QtGui.QSystemTrayIcon will automatically add an entry in the system tray if it is visible() .

    PySide.QtGui.QSystemTrayIcon. isVisible ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the system tray entry is visible.

    Setting this property to true or calling PySide.QtGui.QSystemTrayIcon.show() makes the system tray icon visible; setting this property to false or calling PySide.QtGui.QSystemTrayIcon.hide() hides it.

    PySide.QtGui.QSystemTrayIcon. messageClicked ( )
    PySide.QtGui.QSystemTrayIcon. setContextMenu ( menu )
    参数: menu PySide.QtGui.QMenu

    设置指定 menu 成为用于系统托盘图标的上下文菜单。

    菜单会弹出,当用户通过点击鼠标按钮请求用于系统托盘图标的上下文菜单时。

    On Mac OS X, this is currenly converted to a NSMenu, so the aboutToHide() signal is not emitted.

    注意

    The system tray icon does not take ownership of the menu. You must ensure that it is deleted at the appropriate time by, for example, creating the menu with a suitable parent object.

    PySide.QtGui.QSystemTrayIcon. setIcon ( icon )
    参数: icon PySide.QtGui.QIcon

    This property holds the system tray icon.

    On Windows, the system tray icon size is 16x16; on X11, the preferred size is 22x22. The icon will be scaled to the appropriate size as necessary.

    PySide.QtGui.QSystemTrayIcon. setToolTip ( tip )
    参数: tip – unicode

    This property holds the tooltip for the system tray entry.

    On some systems, the tooltip's length is limited. The tooltip will be truncated if necessary.

    PySide.QtGui.QSystemTrayIcon. setVisible ( visible )
    参数: visible PySide.QtCore.bool

    This property holds whether the system tray entry is visible.

    Setting this property to true or calling PySide.QtGui.QSystemTrayIcon.show() makes the system tray icon visible; setting this property to false or calling PySide.QtGui.QSystemTrayIcon.hide() hides it.

    PySide.QtGui.QSystemTrayIcon. show ( )

    在系统托盘展示图标。

    PySide.QtGui.QSystemTrayIcon. showMessage ( title , msg [ , icon=Information [ , msecs=10000 ] ] )
    参数:

    Shows a balloon message for the entry with the given title , message and icon for the time specified in millisecondsTimeoutHint . title and message must be plain text strings.

    Message can be clicked by the user; the PySide.QtGui.QSystemTrayIcon.messageClicked() signal will emitted when this occurs.

    Note that display of messages are dependent on the system configuration and user preferences, and that messages may not appear at all. Hence, it should not be relied upon as the sole means for providing critical information.

    在 Windows, millisecondsTimeoutHint is usually ignored by the system when the application has focus.

    On Mac OS X, the Growl notification system must be installed for this function to display messages.

    static PySide.QtGui.QSystemTrayIcon. supportsMessages ( )
    返回类型: PySide.QtCore.bool

    Returns true if the system tray supports balloon messages; otherwise returns false.

    PySide.QtGui.QSystemTrayIcon. toolTip ( )
    返回类型: unicode

    This property holds the tooltip for the system tray entry.

    On some systems, the tooltip's length is limited. The tooltip will be truncated if necessary.