QSystemTrayIconclass provides an icon for an application in the system tray. 更多 …
def
contextMenu
()
def
geometry
()
def
icon
()
def
isVisible
()
def
setContextMenu
(menu)
def
setIcon
(icon)
def
setToolTip
(tip)
def
toolTip
()
def
hide
()
def
setVisible
(visible)
def
show
()
def
showMessage
(title, msg, icon[, msecs=10000])
def
showMessage
(title, msg[, icon=QSystemTrayIcon.Information[, msecs=10000]])
def
activated
(reason)
def
messageClicked
()
def
isSystemTrayAvailable
()
def
supportsMessages
()
现代操作系统通常在桌面提供特殊区域,称为 系统托盘 or 通知区域 ,在那里长时间运行应用程序可以显示图标和短消息。
![]()
QSystemTrayIconclass can be used on the following platforms:
所有支持的 Windows 版本。
用于 X11 的所有窗口管理器和独立托盘实现,实现 http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html freedesktop.org XEmbed 系统托盘规范。
所有 X11 桌面环境实现 D-Bus http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem 规范,包括最近版本的 KDE 和 Unity。
所有支持的 macOS 版本。
To check whether a system tray is present on the user’s desktop, call the
isSystemTrayAvailable()static function.To add a system tray entry, create a
QSystemTrayIconobject, callsetContextMenu()to provide a context menu for the icon, and callshow()to make it visible in the system tray. Status notification messages (“balloon messages”) can be displayed at any time usingshowMessage().If the system tray is unavailable when a system tray icon is constructed, but becomes available later,
QSystemTrayIconwill automatically add an entry for the application in the system tray if the icon isvisible.
activated()signal is emitted when the user activates the icon.Only on X11, when a tooltip is requested, the
QSystemTrayIcon接收QHelpEventof typeToolTip. Additionally, theQSystemTrayIconreceives wheel events of typeWheel。这些不被支持,在任何其它平台。
QSystemTrayIcon
(
[
parent=None
]
)
¶
QSystemTrayIcon(icon[, parent=None])
- param parent
QObject- param icon
QIcon
构造
QSystemTrayIcon
对象采用给定
parent
.
图标最初是不可见的。
另请参阅
visible
构造
QSystemTrayIcon
对象采用给定
icon
and
parent
.
图标最初是不可见的。
另请参阅
visible
PySide2.QtWidgets.QSystemTrayIcon.
ActivationReason
¶
此枚举描述系统托盘被激活的原因。
|
常量 |
描述 |
|---|---|
|
QSystemTrayIcon.Unknown |
未知原因 |
|
QSystemTrayIcon.Context |
用于系统托盘条目的上下文菜单被请求 |
|
QSystemTrayIcon.DoubleClick |
系统托盘条目被双击。 |
注意
On macOS, a double click will only be emitted if no context menu is set, since the menu opens on mouse press
|
常量 |
描述 |
|---|---|
|
QSystemTrayIcon.Trigger |
系统托盘条目被点击 |
|
QSystemTrayIcon.MiddleClick |
系统托盘条目被点击,采用鼠标中键 |
另请参阅
PySide2.QtWidgets.QSystemTrayIcon.
MessageIcon
¶
此枚举描述展示图标,当显示气球消息时。
|
常量 |
描述 |
|---|---|
|
QSystemTrayIcon.NoIcon |
没有展示图标。 |
|
QSystemTrayIcon.Information |
展示信息图标。 |
|
QSystemTrayIcon.Warning |
展示标准警告图标。 |
|
QSystemTrayIcon.Critical |
展示严重警告图标。 |
另请参阅
PySide2.QtWidgets.QSystemTrayIcon.
activated
(
reason
)
¶
reason
–
ActivationReason
PySide2.QtWidgets.QSystemTrayIcon.
contextMenu
(
)
¶
Returns the current context menu for the system tray entry.
另请参阅
PySide2.QtWidgets.QSystemTrayIcon.
geometry
(
)
¶
QRect
Returns the geometry of the system tray icon in screen coordinates.
另请参阅
visible
PySide2.QtWidgets.QSystemTrayIcon.
isSystemTrayAvailable
(
)
¶
bool
返回
true
if the system tray is available; otherwise returns
false
.
If the system tray is currently unavailable but becomes available later,
QSystemTrayIcon
will automatically add an entry in the system tray if it is
visible
.
PySide2.QtWidgets.QSystemTrayIcon.
isVisible
(
)
¶
bool
PySide2.QtWidgets.QSystemTrayIcon.
messageClicked
(
)
¶
PySide2.QtWidgets.QSystemTrayIcon.
setContextMenu
(
menu
)
¶
menu
–
QMenu
设置指定
menu
成为用于系统托盘图标的上下文菜单。
菜单会弹出,当用户通过点击鼠标按钮请求用于系统托盘图标的上下文菜单时。
On macOS, 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.
另请参阅
PySide2.QtWidgets.QSystemTrayIcon.
setVisible
(
visible
)
¶
visible
–
bool
另请参阅
PySide2.QtWidgets.QSystemTrayIcon.
showMessage
(
title
,
msg
[
,
icon=QSystemTrayIcon.Information
[
,
msecs=10000
]
]
)
¶
title – unicode
msg – unicode
icon
–
MessageIcon
msecs
–
int
PySide2.QtWidgets.QSystemTrayIcon.
showMessage
(
title
,
msg
,
icon
[
,
msecs=10000
]
)
¶
title – unicode
msg – unicode
icon
–
QIcon
msecs
–
int
PySide2.QtWidgets.QSystemTrayIcon.
supportsMessages
(
)
¶
bool
返回
true
if the system tray supports balloon messages; otherwise returns
false
.
另请参阅
PySide2.QtWidgets.QSystemTrayIcon.
toolTip
(
)
¶
unicode
另请参阅