Merge pull request #1121 from nanoric/openApp

[Add] 新增openApp系列函数
This commit is contained in:
vn.py 2018-09-21 09:57:05 +08:00 committed by GitHub
commit 7fd1d55dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,9 +190,21 @@ class MainWindow(QtWidgets.QMainWindow):
return action return action
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def createOpenAppFunction(self, appDetail): def openApp(self, appModule):
"""创建打开应用UI的函数""" """打开一个app这个app必须是MainEngine.addApp添加过的"""
def openAppFunction(): 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'] appName = appDetail['appName']
try: try:
self.widgetDict[appName].show() self.widgetDict[appName].show()
@ -200,6 +212,14 @@ class MainWindow(QtWidgets.QMainWindow):
appEngine = self.mainEngine.getApp(appName) appEngine = self.mainEngine.getApp(appName)
self.widgetDict[appName] = appDetail['appWidget'](appEngine, self.eventEngine) self.widgetDict[appName] = appDetail['appWidget'](appEngine, self.eventEngine)
self.widgetDict[appName].show() self.widgetDict[appName].show()
return self.widgetDict[appName]
#----------------------------------------------------------------------
def createOpenAppFunction(self, appDetail):
"""创建打开应用UI的函数"""
def openAppFunction():
return self.openAppByDetail(appDetail)
return openAppFunction return openAppFunction