2015-10-16 08:50:44 +00:00
|
|
|
|
# encoding: UTF-8
|
|
|
|
|
|
|
|
|
|
import sys
|
2016-10-28 14:55:46 +00:00
|
|
|
|
import os
|
2015-10-16 08:50:44 +00:00
|
|
|
|
import ctypes
|
2016-04-28 23:47:29 +00:00
|
|
|
|
import platform
|
2015-10-16 08:50:44 +00:00
|
|
|
|
|
2016-10-28 14:55:46 +00:00
|
|
|
|
import vtPath
|
2015-10-16 08:50:44 +00:00
|
|
|
|
from vtEngine import MainEngine
|
|
|
|
|
from uiMainWindow import *
|
|
|
|
|
|
2016-10-28 14:55:46 +00:00
|
|
|
|
# 文件路径名
|
|
|
|
|
path = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
ICON_FILENAME = 'vnpy.ico'
|
|
|
|
|
ICON_FILENAME = os.path.join(path, ICON_FILENAME)
|
|
|
|
|
|
|
|
|
|
SETTING_FILENAME = 'VT_setting.json'
|
|
|
|
|
SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
|
|
|
|
|
2015-10-16 08:50:44 +00:00
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
def main():
|
|
|
|
|
"""主程序入口"""
|
2016-04-30 02:11:52 +00:00
|
|
|
|
# 重载sys模块,设置默认字符串编码方式为utf8
|
2016-04-29 05:42:29 +00:00
|
|
|
|
reload(sys)
|
|
|
|
|
sys.setdefaultencoding('utf8')
|
2016-04-30 02:11:52 +00:00
|
|
|
|
|
|
|
|
|
# 设置Windows底部任务栏图标
|
2016-05-05 14:26:19 +00:00
|
|
|
|
if 'Windows' in platform.uname() :
|
2016-04-30 02:11:52 +00:00
|
|
|
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')
|
2016-10-28 14:55:46 +00:00
|
|
|
|
|
2016-04-28 15:03:36 +00:00
|
|
|
|
# 初始化Qt应用对象
|
2015-10-16 08:50:44 +00:00
|
|
|
|
app = QtGui.QApplication(sys.argv)
|
2016-10-28 14:55:46 +00:00
|
|
|
|
app.setWindowIcon(QtGui.QIcon(ICON_FILENAME))
|
2015-10-16 08:50:44 +00:00
|
|
|
|
app.setFont(BASIC_FONT)
|
|
|
|
|
|
2016-04-28 15:03:36 +00:00
|
|
|
|
# 设置Qt的皮肤
|
|
|
|
|
try:
|
2016-10-28 14:55:46 +00:00
|
|
|
|
f = file(SETTING_FILENAME)
|
2016-04-28 15:03:36 +00:00
|
|
|
|
setting = json.load(f)
|
|
|
|
|
if setting['darkStyle']:
|
|
|
|
|
import qdarkstyle
|
|
|
|
|
app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
|
2017-03-19 08:10:05 +00:00
|
|
|
|
f.close()
|
2016-04-28 15:03:36 +00:00
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# 初始化主引擎和主窗口对象
|
2015-10-16 08:50:44 +00:00
|
|
|
|
mainEngine = MainEngine()
|
2015-12-30 14:01:17 +00:00
|
|
|
|
mainWindow = MainWindow(mainEngine, mainEngine.eventEngine)
|
2015-10-16 08:50:44 +00:00
|
|
|
|
mainWindow.showMaximized()
|
|
|
|
|
|
2016-04-28 15:03:36 +00:00
|
|
|
|
# 在主线程中启动Qt事件循环
|
2015-10-16 08:50:44 +00:00
|
|
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
main()
|