本文整理汇总了Python中PyQt4.QtGui.QSystemTrayIcon.setToolTipSubTitle方法的典型用法代码示例。如果您正苦于以下问题:Python QSystemTrayIcon.setToolTipSubTitle方法的具体用法?Python QSystemTrayIcon.setToolTipSubTitle怎么用?Python QSystemTrayIcon.setToolTipSubTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QSystemTrayIcon
的用法示例。
在下文中一共展示了QSystemTrayIcon.setToolTipSubTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tray
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setToolTipSubTitle [as 别名]
class Tray(QObject):
activated = pyqtSignal()
def __init__(self, parent, title, icon):
QObject.__init__(self)
# Setup contextual menu
if kde:
self.menu = KMenu(parent)
self.tray = KStatusNotifierItem(parent)
self.tray.setStatus(KStatusNotifierItem.Passive)
self.tray.setCategory(KStatusNotifierItem.ApplicationStatus)
self.tray.setAssociatedWidget(parent)
self.tray.setStandardActionsEnabled(False)
self.tray.activateRequested.connect(self._activateRequested)
else:
self.menu = QMenu()
self.tray = QSystemTrayIcon()
self.tray.activated.connect(self._activated)
self.setIcon(icon)
self.setTitle(title)
if not kde:
self.tray.show()
self.tray.setContextMenu(self.menu)
def setActive(self, active=True):
if kde:
self.tray.setStatus(KStatusNotifierItem.Active if active else KStatusNotifierItem.Passive)
def setTitle(self, title):
if kde:
self.tray.setTitle(title)
self.tray.setToolTipTitle(title)
else:
self.tray.setToolTip(title)
self.menu.setTitle(title)
def setToolTipSubTitle(self, subtitle):
if kde:
self.tray.setToolTipSubTitle(subtitle)
def setIcon(self, icon):
if kde:
self.tray.setIconByPixmap(icon)
self.tray.setToolTipIconByPixmap(icon)
else:
self.tray.setIcon(icon)
def showMessage(self, title, message, icon=None):
if kde:
self.tray.showMessage(title, message, "network-server")
else:
self.tray.showMessage(title, message, QSystemTrayIcon.Information if icon is None else icon)
def _activated(self, reason):
if reason == QSystemTrayIcon.DoubleClick:
self.activated.emit()
def _activateRequested(self, active, pos):
self.activated.emit()
示例2: GlobalSysTray
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setToolTipSubTitle [as 别名]
#.........这里部分代码省略.........
i = self.get_act_index(act_name_id)
if i < 0: return
act_widget = self.act_indexes[i][iActWidget]
if TrayEngine == "KDE":
act_widget.setText(text)
elif TrayEngine == "AppIndicator":
if isinstance(act_widget, Gtk.ImageMenuItem):
# Fix icon reset
last_icon = act_widget.get_image()
act_widget.set_label(text)
act_widget.set_image(last_icon)
else:
act_widget.set_label(text)
elif TrayEngine == "Qt":
act_widget.setText(text)
def setIcon(self, icon):
if TrayEngine == "KDE":
self.tray.setIconByPixmap(getIcon(icon))
#self.tray.setToolTipIconByPixmap(getIcon(icon))
elif TrayEngine == "AppIndicator":
self.tray.set_icon(icon)
elif TrayEngine == "Qt":
self.tray.setIcon(getIcon(icon))
def setToolTip(self, text):
if TrayEngine == "KDE":
self.tray.setToolTipSubTitle(text)
elif TrayEngine == "AppIndicator":
# ToolTips are disabled in App-Indicators by design
pass
elif TrayEngine == "Qt":
self.tray.setToolTip(text)
# -------------------------------------------------------------------------------------------
#def removeAction(self, act_name_id):
#index = self.get_act_index(act_name_id)
#if index < 0: return
#act_widget = self.act_indexes[index][1]
#parent_menu_widget = self.get_parent_menu_widget(self.act_indexes[index][2])
##if TrayEngine == "KDE":
##parent_menu_widget.removeAction(act_widget)
##elif TrayEngine == "AppIndicator":
##act_widget.hide()
##parent_menu_widget.remove(act_widget)
##else:
#if (1):
#parent_menu_widget.removeAction(act_widget)
#self.act_indexes.pop(index)
#def removeSeparator(self, sep_name_id):
#index = self.get_sep_index(sep_name_id)
#if index < 0: return
#sep_widget = self.sep_indexes[index][1]
#parent_menu_widget = self.get_parent_menu_widget(self.sep_indexes[index][2])
##if TrayEngine == "KDE":
##parent_menu_widget.removeAction(sep_widget)