修改QApp对象需要用户显式调用createQApp函数后创建
This commit is contained in:
parent
b574af80f1
commit
e8ae262660
@ -64,7 +64,7 @@ sys.setdefaultencoding('utf8')
|
|||||||
# vn.trader模块
|
# vn.trader模块
|
||||||
from vnpy.event import EventEngine
|
from vnpy.event import EventEngine
|
||||||
from vnpy.trader.vtEngine import MainEngine
|
from vnpy.trader.vtEngine import MainEngine
|
||||||
from vnpy.trader.uiQt import qApp
|
from vnpy.trader.uiQt import createQApp
|
||||||
from vnpy.trader.uiMainWindow import MainWindow
|
from vnpy.trader.uiMainWindow import MainWindow
|
||||||
|
|
||||||
# 加载底层接口
|
# 加载底层接口
|
||||||
@ -77,6 +77,9 @@ from vnpy.trader.app import riskManager, ctaStrategy
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def main():
|
def main():
|
||||||
"""主程序入口"""
|
"""主程序入口"""
|
||||||
|
# 创建Qt应用对象
|
||||||
|
qApp = createQApp()
|
||||||
|
|
||||||
# 创建事件引擎
|
# 创建事件引擎
|
||||||
ee = EventEngine()
|
ee = EventEngine()
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ system = platform.system()
|
|||||||
# vn.trader模块
|
# vn.trader模块
|
||||||
from vnpy.event import EventEngine
|
from vnpy.event import EventEngine
|
||||||
from vnpy.trader.vtEngine import MainEngine
|
from vnpy.trader.vtEngine import MainEngine
|
||||||
from vnpy.trader.uiQt import qApp
|
from vnpy.trader.uiQt import createQApp
|
||||||
from vnpy.trader.uiMainWindow import MainWindow
|
from vnpy.trader.uiMainWindow import MainWindow
|
||||||
|
|
||||||
# 加载底层接口
|
# 加载底层接口
|
||||||
@ -30,6 +30,9 @@ from vnpy.trader.app import (riskManager, ctaStrategy, spreadTrading)
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def main():
|
def main():
|
||||||
"""主程序入口"""
|
"""主程序入口"""
|
||||||
|
# 创建Qt应用对象
|
||||||
|
qApp = createQApp()
|
||||||
|
|
||||||
# 创建事件引擎
|
# 创建事件引擎
|
||||||
ee = EventEngine()
|
ee = EventEngine()
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ from vnpy.rpc import RpcClient
|
|||||||
|
|
||||||
from vnpy.trader.vtGlobal import globalSetting
|
from vnpy.trader.vtGlobal import globalSetting
|
||||||
from vnpy.trader.vtEngine import MainEngine
|
from vnpy.trader.vtEngine import MainEngine
|
||||||
from vnpy.trader.uiQt import qApp
|
from vnpy.trader.uiQt import createQApp
|
||||||
from vnpy.trader.uiMainWindow import MainWindow
|
from vnpy.trader.uiMainWindow import MainWindow
|
||||||
|
|
||||||
|
|
||||||
@ -148,6 +148,9 @@ class ClientEngine(MainEngine):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def main():
|
def main():
|
||||||
"""客户端主程序入口"""
|
"""客户端主程序入口"""
|
||||||
|
# 创建Qt对象
|
||||||
|
qApp = createQApp()
|
||||||
|
|
||||||
# 创建事件引擎
|
# 创建事件引擎
|
||||||
eventEngine = EventEngine2()
|
eventEngine = EventEngine2()
|
||||||
eventEngine.start(timer=False)
|
eventEngine.start(timer=False)
|
||||||
|
@ -7,30 +7,37 @@ from qtpy import QtWidgets, QtGui, QtCore
|
|||||||
from vnpy.trader.vtGlobal import globalSetting
|
from vnpy.trader.vtGlobal import globalSetting
|
||||||
from vnpy.trader.vtFunction import loadIconPath
|
from vnpy.trader.vtFunction import loadIconPath
|
||||||
|
|
||||||
# 创建Qt应用对象
|
|
||||||
qApp = QtWidgets.QApplication([])
|
|
||||||
|
|
||||||
# 设置Qt的皮肤
|
#----------------------------------------------------------------------
|
||||||
if globalSetting['darkStyle']:
|
def createQApp():
|
||||||
try:
|
"""创建PyQt应用对象"""
|
||||||
import qdarkstyle
|
# 创建Qt应用对象
|
||||||
qApp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
|
qApp = QtWidgets.QApplication([])
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# 设置Windows底部任务栏图标
|
# 设置Qt的皮肤
|
||||||
if 'Windows' in platform.uname():
|
if globalSetting['darkStyle']:
|
||||||
import ctypes
|
try:
|
||||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')
|
import qdarkstyle
|
||||||
|
qApp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
|
||||||
# 设置Qt字体
|
except ImportError:
|
||||||
try:
|
pass
|
||||||
family = globalSetting['fontFamily']
|
|
||||||
size = globalSetting['fontSize']
|
# 设置Windows底部任务栏图标
|
||||||
BASIC_FONT = QtGui.QFont(family, size)
|
if 'Windows' in platform.uname():
|
||||||
except:
|
import ctypes
|
||||||
BASIC_FONT = QtGui.QFont(u'微软雅黑', 12)
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')
|
||||||
qApp.setFont(BASIC_FONT)
|
|
||||||
|
# 设置Qt字体
|
||||||
# 设置Qt图标
|
try:
|
||||||
qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))
|
family = globalSetting['fontFamily']
|
||||||
|
size = globalSetting['fontSize']
|
||||||
|
BASIC_FONT = QtGui.QFont(family, size)
|
||||||
|
except:
|
||||||
|
BASIC_FONT = QtGui.QFont(u'微软雅黑', 12)
|
||||||
|
qApp.setFont(BASIC_FONT)
|
||||||
|
|
||||||
|
# 设置Qt图标
|
||||||
|
qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))
|
||||||
|
|
||||||
|
# 返回创建好的QApp对象
|
||||||
|
return qApp
|
Loading…
Reference in New Issue
Block a user