增加菜单栏图标
@ -6,4 +6,5 @@ from uiCtaWidget import CtaEngineManager
|
||||
appName = 'CtaStrategy'
|
||||
appDisplayName = u'CTA策略'
|
||||
appEngine = CtaEngine
|
||||
appWidget = CtaEngineManager
|
||||
appWidget = CtaEngineManager
|
||||
appIco = 'cta.ico'
|
BIN
vnpy/trader/app/ctaStrategy/cta.ico
Normal file
After Width: | Height: | Size: 66 KiB |
@ -35,6 +35,8 @@ from vnpy.trader.app.ctaStrategy.ctaBase import *
|
||||
from vnpy.trader.app.ctaStrategy.strategy import STRATEGY_CLASS
|
||||
|
||||
|
||||
|
||||
|
||||
########################################################################
|
||||
class CtaEngine(object):
|
||||
"""CTA策略引擎"""
|
||||
|
@ -6,4 +6,5 @@ from uiDrWidget import DrEngineManager
|
||||
appName = 'DataRecorder'
|
||||
appDisplayName = u'行情记录'
|
||||
appEngine = DrEngine
|
||||
appWidget = DrEngineManager
|
||||
appWidget = DrEngineManager
|
||||
appIco = 'dr.ico'
|
BIN
vnpy/trader/app/dataRecorder/dr.ico
Normal file
After Width: | Height: | Size: 66 KiB |
@ -6,4 +6,5 @@ from uiRmWidget import RmEngineManager
|
||||
appName = 'RiskManager'
|
||||
appDisplayName = u'风险管理'
|
||||
appEngine = RmEngine
|
||||
appWidget = RmEngineManager
|
||||
appWidget = RmEngineManager
|
||||
appIco = 'rm.ico'
|
BIN
vnpy/trader/app/riskManager/rm.ico
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
vnpy/trader/archive/app.ico
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
vnpy/trader/archive/help.ico
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
vnpy/trader/archive/system.ico
Normal file
After Width: | Height: | Size: 66 KiB |
@ -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
After Width: | Height: | Size: 66 KiB |
BIN
vnpy/trader/ico/connect.ico
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
vnpy/trader/ico/contract.ico
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
vnpy/trader/ico/database.ico
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
vnpy/trader/ico/exit.ico
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
vnpy/trader/ico/restore.ico
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
vnpy/trader/ico/test.ico
Normal file
After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
@ -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
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -33,4 +33,4 @@ except:
|
||||
qApp.setFont(BASIC_FONT)
|
||||
|
||||
# 设置Qt图标
|
||||
qApp.setWindowIcon(QtGui.QIcon(loadIconPath()))
|
||||
qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))
|
@ -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)
|
||||
|
||||
|
@ -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():
|
||||
"""加载程序图标路径"""
|
||||
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
|
||||
|
||||
def loadIconPath(iconName):
|
||||
"""加载程序图标路径"""
|
||||
global iconPathDict
|
||||
return iconPathDict.get(iconName, '')
|
||||
|
||||
|
||||
|
||||
|