From f42d5d7af6324e75a450db7d03deea1b9f9aa7a2 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Mon, 2 Apr 2018 12:51:21 +0100 Subject: [PATCH] plugin_app() can return None so it can be used as a callback after the main window and all other plugins are initialised. --- PLUGINS.md | 4 ++-- plug.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/PLUGINS.md b/PLUGINS.md index 72e21c77..46f55230 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -85,9 +85,9 @@ def prefs_changed(cmdr, is_beta): ## Display -You can also have your plugin add an item to the EDMC main window and update it if you need to from your event hooks. This works in the same way as `plugin_prefs()`. For a simple one-line item return a tk.Label widget or a pair of widgets as a tuple. For a more complicated item create a tk.Frame widget and populate it with other ttk widgets. +You can also have your plugin add an item to the EDMC main window and update from your event hooks. This works in the same way as `plugin_prefs()`. For a simple one-line item return a tk.Label widget or a pair of widgets as a tuple. For a more complicated item create a tk.Frame widget and populate it with other ttk widgets. Return `None` if you just want to use this as a callback after the main window and all other plugins are initialised. -You can use `stringFromNumber()` from EDMC's `l10n.Locale` object to format numbers in a locale-independent way. +You can use `stringFromNumber()` from EDMC's `l10n.Locale` object to format numbers in your widgets in a locale-independent way. ```python this = sys.modules[__name__] # For holding module globals diff --git a/plug.py b/plug.py index 6022bab4..32074400 100644 --- a/plug.py +++ b/plug.py @@ -107,12 +107,15 @@ class Plugin(object): if plugin_app: try: appitem = plugin_app(parent) - if isinstance(appitem, tuple): + if appitem is None: + return None + elif isinstance(appitem, tuple): if len(appitem) != 2 or not isinstance(appitem[0], tk.Widget) or not isinstance(appitem[1], tk.Widget): raise AssertionError elif not isinstance(appitem, tk.Widget): raise AssertionError - return appitem + else: + return appitem except: print_exc() return None