本文整理汇总了Python中PyQt4.QtGui.QSystemTrayIcon.setStandardActionsEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QSystemTrayIcon.setStandardActionsEnabled方法的具体用法?Python QSystemTrayIcon.setStandardActionsEnabled怎么用?Python QSystemTrayIcon.setStandardActionsEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QSystemTrayIcon
的用法示例。
在下文中一共展示了QSystemTrayIcon.setStandardActionsEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tray
# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setStandardActionsEnabled [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()