From b9d41a1d5559d7a63fd1a6653ccef3c8fb491b8c Mon Sep 17 00:00:00 2001 From: nanoric Date: Wed, 19 Sep 2018 05:35:18 -0400 Subject: [PATCH] =?UTF-8?q?[Add]=20=E6=96=B0=E5=A2=9EopenApp=E7=B3=BB?= =?UTF-8?q?=E5=88=97=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/uiMainWindow.py | 38 ++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/vnpy/trader/uiMainWindow.py b/vnpy/trader/uiMainWindow.py index 38f52333..8e0f555a 100644 --- a/vnpy/trader/uiMainWindow.py +++ b/vnpy/trader/uiMainWindow.py @@ -188,19 +188,39 @@ class MainWindow(QtWidgets.QMainWindow): action.setIcon(icon) return action - + + #---------------------------------------------------------------------- + def openApp(self, appModule): + """打开一个app,这个app必须是MainEngine.addApp添加过的""" + name = appModule.appName + return self.openAppByName(name) + + #---------------------------------------------------------------------- + def openAppByName(self, appName): + detail = [i for i in self.appDetailList if i['appName'] == appName][0] + return self.openAppByDetail(detail) + + #---------------------------------------------------------------------- + def openAppByDetail(self, appDetail): + """打开一个app + :return 返回app的窗口 + """ + appName = appDetail['appName'] + try: + self.widgetDict[appName].show() + except KeyError: + appEngine = self.mainEngine.getApp(appName) + self.widgetDict[appName] = appDetail['appWidget'](appEngine, self.eventEngine) + self.widgetDict[appName].show() + return self.widgetDict[appName] + #---------------------------------------------------------------------- def createOpenAppFunction(self, appDetail): """创建打开应用UI的函数""" + def openAppFunction(): - appName = appDetail['appName'] - try: - self.widgetDict[appName].show() - except KeyError: - appEngine = self.mainEngine.getApp(appName) - self.widgetDict[appName] = appDetail['appWidget'](appEngine, self.eventEngine) - self.widgetDict[appName].show() - + return self.openAppByDetail(appDetail) + return openAppFunction #----------------------------------------------------------------------