Skip to content

Commit a9ac63f

Browse files
committed
give warning message if a plugin doesn't work
1 parent 1e3f1a4 commit a9ac63f

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

src/navigate/controller/sub_controllers/plugins_controller.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import os
3636
import inspect
3737
import tkinter as tk
38+
from tkinter import messagebox
3839

3940
# Third-party imports
4041

@@ -138,13 +139,18 @@ def load_plugins(self):
138139
f"Make sure that the plugin frame name {plugin_class_name} is correct! "
139140
f"Plugin {plugin_name} needs to be uninstalled from navigate or reinstalled!"
140141
)
141-
return
142+
continue
142143
plugin_frame = getattr(
143144
plugin_frame_module, f"{plugin_class_name}Frame"
144145
)
145146
plugin_controller_module = load_module_from_file(
146147
f"{plugin_class_name}Controller", controller_file
147148
)
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+
)
148154
plugin_controller = getattr(
149155
plugin_controller_module, f"{plugin_class_name}Controller"
150156
)
@@ -208,13 +214,22 @@ def build_tab_window(self, plugin_name, frame, controller):
208214
controller: object
209215
navigate controller
210216
"""
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+
)
218233

219234
def build_popup_window(self, plugin_name, frame, controller):
220235
"""Build popup window for a plugin
@@ -264,7 +279,19 @@ def func(*args, **kwargs):
264279
),
265280
)
266281

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
268295

269296

270297
class UninstallPluginController(GUIController):

0 commit comments

Comments
 (0)