|
35 | 35 | import os |
36 | 36 | import inspect |
37 | 37 | import tkinter as tk |
| 38 | +from tkinter import messagebox |
38 | 39 |
|
39 | 40 | # Third-party imports |
40 | 41 |
|
@@ -138,13 +139,18 @@ def load_plugins(self): |
138 | 139 | f"Make sure that the plugin frame name {plugin_class_name} is correct! " |
139 | 140 | f"Plugin {plugin_name} needs to be uninstalled from navigate or reinstalled!" |
140 | 141 | ) |
141 | | - return |
| 142 | + continue |
142 | 143 | plugin_frame = getattr( |
143 | 144 | plugin_frame_module, f"{plugin_class_name}Frame" |
144 | 145 | ) |
145 | 146 | plugin_controller_module = load_module_from_file( |
146 | 147 | f"{plugin_class_name}Controller", controller_file |
147 | 148 | ) |
| 149 | + if plugin_controller_module is None: |
| 150 | + print( |
| 151 | + f"Make sure that the plugin controller {plugin_class_name} is correct! " |
| 152 | + f"Plugin {plugin_name} needs to be uninstalled from navigate or reinstalled!" |
| 153 | + ) |
148 | 154 | plugin_controller = getattr( |
149 | 155 | plugin_controller_module, f"{plugin_class_name}Controller" |
150 | 156 | ) |
@@ -208,13 +214,22 @@ def build_tab_window(self, plugin_name, frame, controller): |
208 | 214 | controller: object |
209 | 215 | navigate controller |
210 | 216 | """ |
211 | | - plugin_frame = frame(self.view.settings) |
212 | | - self.view.settings.add(plugin_frame, text=plugin_name, sticky=tk.NSEW) |
213 | | - plugin_controller = controller(plugin_frame, self.parent_controller) |
214 | | - controller_name = ( |
215 | | - "__plugin" + "_".join(plugin_name.lower().split()) + "_controller" |
216 | | - ) |
217 | | - self.plugins_dict[controller_name] = plugin_controller |
| 217 | + try: |
| 218 | + plugin_frame = frame(self.view.settings) |
| 219 | + self.view.settings.add(plugin_frame, text=plugin_name, sticky=tk.NSEW) |
| 220 | + plugin_controller = controller(plugin_frame, self.parent_controller) |
| 221 | + controller_name = ( |
| 222 | + "__plugin" + "_".join(plugin_name.lower().split()) + "_controller" |
| 223 | + ) |
| 224 | + self.plugins_dict[controller_name] = plugin_controller |
| 225 | + except: |
| 226 | + messagebox.showwarning( |
| 227 | + title="Warning", |
| 228 | + message=( |
| 229 | + f"Plugin {plugin_name} has something went wrong." |
| 230 | + f"Please make sure the plugin works correctly or uninstall it!" |
| 231 | + ) |
| 232 | + ) |
218 | 233 |
|
219 | 234 | def build_popup_window(self, plugin_name, frame, controller): |
220 | 235 | """Build popup window for a plugin |
@@ -264,7 +279,19 @@ def func(*args, **kwargs): |
264 | 279 | ), |
265 | 280 | ) |
266 | 281 |
|
267 | | - return func |
| 282 | + def func_with_wrapper(*args, **kwargs): |
| 283 | + try: |
| 284 | + func(*args, **kwargs) |
| 285 | + except: |
| 286 | + messagebox.showwarning( |
| 287 | + title="Warning", |
| 288 | + message=( |
| 289 | + f"Plugin {plugin_name} has something went wrong." |
| 290 | + f"Please make sure the plugin works correctly or uninstall it from navigate!" |
| 291 | + ) |
| 292 | + ) |
| 293 | + |
| 294 | + return func_with_wrapper |
268 | 295 |
|
269 | 296 |
|
270 | 297 | class UninstallPluginController(GUIController): |
|
0 commit comments