# - * - coding: utf-8 - * -
The import sys
# Form implementation generated from reading the UI file 'tt. UI'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
The from PyQt4 import QtCore QtGui, QtNetwork
The from PyQt4. QtCore import pyqtSlot
The from PyQt4. QtCore import *
The from PyQt4. QtGui import *
The from PyQt4 import uic
The import sys
Reload (sys)
Sys. Setdefaultencoding (" utf-8 ")
The class MainWindow (QtGui. QMainWindow) :
Def __init__ (self, parent=None) :
QtGui. QWidget. __init__ (self, parent)
Self. UI=uic. LoadUi (" UI/main_ui. UI ", self)
# the self. The pushButton. Clicked. Connect (self. Func_buttonAdd)
Self. CreateActions () # menu loaded
Self. CreateTrayIcon () # menu loaded
The self. The trayIcon. Activated. Connect (self. IconActivated)
Self. SetIcon ()
Def func_buttonAdd (self) :
QtGui. QMessageBox. About (self, 'PyQt3333333333333333333333333333333', "About222")
Def createTrayIcon (self) : # at the bottom tray menu
Try:
Self. TrayIconMenu=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)
The self. The trayIcon=QSystemTrayIcon (self)
The self. The trayIcon. SetContextMenu (self. TrayIconMenu)
Except BaseException, e:
Print "createTrayIcon," e.m essage
Def setIcon (self) :
Try:
The self. The trayIcon. SetIcon (QtGui QIcon (" system/main. Ico "))
The self. The trayIcon. SetToolTip (" China creation axe ")
The self. The trayIcon. The show ()
Except BaseException, e:
Print "seticon, STR (e)
Def createActions (self) : # menu loaded
Try:
Print "hello", "
Self. MinimizeAction=QAction (u "minimize", the self, triggered=self. The test2)
# self. MaximizeAction=QAction (u "maximize" and the self, triggered=self. ShowMaximized)
# self. RestoreAction=QAction (u "reduction", the self, triggered=self. ShowNormal)
# self. QuitAction=QAction (u "exit", the self, triggered=QApplication. The instance (). The quit)
Except BaseException, e:
Print "creationssssssssssss," e.m essage
Def test2 (self) :
Print "test2
"Def iconActivated (self, "reason) :
Print "tuopan
"Return
Try:
If a tiny (in QSystemTrayIcon. The Trigger, QSystemTrayIcon. DoubleClick) : # click the icon reaction
Self. ShowNormal () # reduction
# triggered=self. ShowNormal
# print (" 111111111111111 ")
# show should be here
# elif reason==QSystemTrayIcon. MiddleClick:
# print (" 22222 ")
Except BaseException, e:
Print STR (e)
If __name__=="__main__" :
Try:
App=QtGui. QApplication (sys. Argv)
Myapp=MainWindow ()
Myapp. The show ()
# QtGui. QMessageBox. Information (myapp, "aa", "aa") # pop-up dialog
Sys. Exit (app. Exec_ ())
Except, e:
Print e.m essage
Directly on the pycharm running without any problems, but the use of python xx. Py run along while didn't find the right tray menu after submenu content then under several main interface card dead
Is this the pyqt bug??? But few play pyqt, down the problem couldn't solve the really basic pit dad,