from focWindow import FocWindow from qSingleApplication import QSingleApplication import sys if __name__ == "__main__": app = QSingleApplication(sys.argv) app.setApplicationName("Foc for Windows") myWindow = FocWindow() app.singleStart(myWindow) sys.exit(app.exec_())
def showMessage(self): icon = QtGui.QSystemTrayIcon.Information self.trayIcon.showMessage(u"提示信息", u"点我干嘛?", icon) def trayMenu(self): self.minimizeAction = QtGui.QAction(u"最小化", self, triggered=self.hide) self.maximizeAction = QtGui.QAction(u"最大化", self, triggered=self.showMaximized) self.restoreAction = QtGui.QAction(u"还原", self, triggered=self.showNormal) self.quitAction = QtGui.QAction(u"退出", self, triggered=QtGui.qApp.quit) self.trayIconMenu = QtGui.QMenu(self) self.trayIconMenu.addAction(self.minimizeAction) self.trayIconMenu.addAction(self.maximizeAction) self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addSeparator() # 间隔线 self.trayIconMenu.addAction(self.quitAction) self.trayIcon.setContextMenu(self.trayIconMenu) # 右击托盘 def getArgsFromOtherInstance(self, args): QtGui.QMessageBox.information(self, self.tr("Received args from another instance"), args) if __name__ == "__main__": import sys app = QSingleApplication(sys.argv) app.setApplicationName("PtProject V 1.0") window = MainWindow() app.singleStart(window) sys.exit(app.exec_())