From fba165f93dcf12a9fbac34eea49b00e3f2f33a00 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Sun, 19 Jan 2020 16:47:34 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=A2=9E=E5=BC=BA]=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=83=A8=E5=88=86APP=E6=B2=A1=E6=9C=89UI=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/ui/mainwindow.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/vnpy/trader/ui/mainwindow.py b/vnpy/trader/ui/mainwindow.py index 2cad1a7b..92c311e0 100644 --- a/vnpy/trader/ui/mainwindow.py +++ b/vnpy/trader/ui/mainwindow.py @@ -107,18 +107,20 @@ class MainWindow(QtWidgets.QMainWindow): all_apps = self.main_engine.get_all_apps() for app in all_apps: - ui_module = import_module(app.app_module + ".ui") - widget_class = getattr(ui_module, app.widget_name) - - func = partial(self.open_widget, widget_class, app.app_name) - icon_path = str(app.app_path.joinpath("ui", app.icon_name)) - self.add_menu_action( - app_menu, app.display_name, icon_path, func - ) - self.add_toolbar_action( - app.display_name, icon_path, func - ) + try: + ui_module = import_module(app.app_module + ".ui") + widget_class = getattr(ui_module, app.widget_name) + func = partial(self.open_widget, widget_class, app.app_name) + icon_path = str(app.app_path.joinpath("ui", app.icon_name)) + self.add_menu_action( + app_menu, app.display_name, icon_path, func + ) + self.add_toolbar_action( + app.display_name, icon_path, func + ) + except Exception as ex: + print(f'加载{app.app_module}出现异常:{str(ex)}') # Global setting editor action = QtWidgets.QAction("配置", self) action.triggered.connect(self.edit_global_setting)