增加菜单栏图标

This commit is contained in:
vn.py 2017-06-01 22:26:44 +08:00
parent 8e5ae0565c
commit 0a504e447b
23 changed files with 47 additions and 41 deletions

View File

@ -7,3 +7,4 @@ appName = 'CtaStrategy'
appDisplayName = u'CTA策略'
appEngine = CtaEngine
appWidget = CtaEngineManager
appIco = 'cta.ico'

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -35,6 +35,8 @@ from vnpy.trader.app.ctaStrategy.ctaBase import *
from vnpy.trader.app.ctaStrategy.strategy import STRATEGY_CLASS
########################################################################
class CtaEngine(object):
"""CTA策略引擎"""

View File

@ -7,3 +7,4 @@ appName = 'DataRecorder'
appDisplayName = u'行情记录'
appEngine = DrEngine
appWidget = DrEngineManager
appIco = 'dr.ico'

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -7,3 +7,4 @@ appName = 'RiskManager'
appDisplayName = u'风险管理'
appEngine = RmEngine
appWidget = RmEngineManager
appIco = 'rm.ico'

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
vnpy/trader/archive/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -2,6 +2,6 @@
"brokerID": "9999",
"mdAddress": "tcp://180.168.146.187:10011",
"tdAddress": "tcp://180.168.146.187:10001",
"userID": "000300",
"password": "19890624"
"userID": "simnow申请",
"password": "simnow申请"
}

BIN
vnpy/trader/ico/about.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
vnpy/trader/ico/connect.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
vnpy/trader/ico/exit.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
vnpy/trader/ico/restore.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
vnpy/trader/ico/test.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -2,6 +2,7 @@
import psutil
from vnpy.trader.vtFunction import loadIconPath
from vnpy.trader.vtGlobal import globalSetting
from vnpy.trader.uiBasicWidget import *
@ -100,34 +101,26 @@ class MainWindow(QtWidgets.QMainWindow):
self.addConnectAction(sysMenu, d['gatewayName'], d['gatewayDisplayName'])
sysMenu.addSeparator()
sysMenu.addAction(self.createAction(vtText.CONNECT_DATABASE, self.mainEngine.dbConnect))
sysMenu.addAction(self.createAction(vtText.CONNECT_DATABASE, self.mainEngine.dbConnect, loadIconPath('database.ico')))
sysMenu.addSeparator()
sysMenu.addAction(self.createAction(vtText.EXIT, self.close))
sysMenu.addAction(self.createAction(vtText.EXIT, self.close, loadIconPath('exit.ico')))
# 功能应用
#functionMenu = menubar.addMenu(vtText.APPLICATION)
#functionMenu.addAction(self.createAction(vtText.DATA_RECORDER, self.openDr))
#functionMenu.addAction(self.createAction(vtText.RISK_MANAGER, self.openRm))
appMenu = menubar.addMenu(vtText.APPLICATION)
for appDetail in self.appDetailList:
function = self.createOpenAppFunction(appDetail)
action = self.createAction(appDetail['appDisplayName'], function)
action = self.createAction(appDetail['appDisplayName'], function, loadIconPath(appDetail['appIco']))
appMenu.addAction(action)
# 算法相关
#strategyMenu = menubar.addMenu(vtText.STRATEGY)
#strategyMenu.addAction(self.createAction(vtText.CTA_STRATEGY, self.openCta))
# 帮助
helpMenu = menubar.addMenu(vtText.HELP)
helpMenu.addAction(self.createAction(vtText.CONTRACT_SEARCH, self.openContract))
helpMenu.addAction(self.createAction(vtText.CONTRACT_SEARCH, self.openContract, loadIconPath('contract.ico')))
helpMenu.addSeparator()
helpMenu.addAction(self.createAction(vtText.RESTORE, self.restoreWindow))
helpMenu.addAction(self.createAction(vtText.ABOUT, self.openAbout))
helpMenu.addAction(self.createAction(vtText.RESTORE, self.restoreWindow, loadIconPath('restore.ico')))
helpMenu.addAction(self.createAction(vtText.ABOUT, self.openAbout, loadIconPath('about.ico')))
helpMenu.addSeparator()
helpMenu.addAction(self.createAction(vtText.TEST, self.test))
helpMenu.addAction(self.createAction(vtText.TEST, self.test, loadIconPath('test.ico')))
#----------------------------------------------------------------------
def initStatusBar(self):
@ -172,14 +165,20 @@ class MainWindow(QtWidgets.QMainWindow):
displayName = gatewayName
actionName = vtText.CONNECT + displayName
menu.addAction(self.createAction(actionName, connect))
connectAction = self.createAction(actionName, connect,
loadIconPath('connect.ico'))
menu.addAction(connectAction)
#----------------------------------------------------------------------
def createAction(self, actionName, function):
def createAction(self, actionName, function, iconPath=''):
"""创建操作功能"""
action = QtWidgets.QAction(actionName, self)
action.triggered.connect(function)
if iconPath:
icon = QtGui.QIcon(iconPath)
action.setIcon(icon)
return action
#----------------------------------------------------------------------

View File

@ -33,4 +33,4 @@ except:
qApp.setFont(BASIC_FONT)
# 设置Qt图标
qApp.setWindowIcon(QtGui.QIcon(loadIconPath()))
qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))

View File

@ -78,7 +78,8 @@ class MainEngine(object):
d = {
'appName': appModule.appName,
'appDisplayName': appModule.appDisplayName,
'appWidget': appModule.appWidget
'appWidget': appModule.appWidget,
'appIco': appModule.appIco
}
self.appDetailList.append(d)

View File

@ -9,9 +9,11 @@ import decimal
import json
from datetime import datetime
MAX_NUMBER = 10000000000000
MAX_DECIMAL = 4
#----------------------------------------------------------------------
def safeUnicode(value):
"""检查接口数据潜在的错误,保证转化为的字符串正确"""
@ -28,28 +30,27 @@ def safeUnicode(value):
return unicode(value)
#----------------------------------------------------------------------
def todayDate():
"""获取当前本机电脑时间的日期"""
return datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
# 图标路径
iconPathDict = {}
path = os.path.abspath(os.path.dirname(__file__))
for root, subdirs, files in os.walk(path):
for fileName in files:
if '.ico' in fileName:
iconPathDict[fileName] = os.path.join(root, fileName)
#----------------------------------------------------------------------
def loadIconPath():
def loadIconPath(iconName):
"""加载程序图标路径"""
iconName = 'vnpy.ico'
# 首先尝试从当前目录加载图标
path = os.getcwd()
iconPath = os.path.join(path, iconName)
if os.path.isfile(iconPath):
return iconPath
# 如果失败则从vt根目录加载图标
else:
path = os.path.abspath(os.path.dirname(__file__))
iconPath = os.path.join(path, iconName)
return iconPath
global iconPathDict
return iconPathDict.get(iconName, '')