diff src/browser/sat_browser/base_widget.py @ 632:c2abadf31afb frontends_multi_profiles

browser side (menu): minor improvments: - use of new style class for MenuCmd and PluginMenuCmd (useless for pyjamas, but can be useful in the future) - use of try/except instead of hasattr - do not use "None" for WidgetMenuBar's __init__
author Goffi <goffi@goffi.org>
date Mon, 23 Feb 2015 18:43:08 +0100
parents 5baca9d46c34
children 40c3c6aaafaa
line wrap: on
line diff
--- a/src/browser/sat_browser/base_widget.py	Mon Feb 23 18:20:04 2015 +0100
+++ b/src/browser/sat_browser/base_widget.py	Mon Feb 23 18:43:08 2015 +0100
@@ -223,10 +223,13 @@
             menu_styles.update(styles)
         base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, styles=menu_styles)
 
-        if hasattr(parent, 'addMenus'):
-            # regroup all the dynamic menu categories in a sub-menu
-            sub_menu = WidgetSubMenuBar(host, vertical=True)
+        # regroup all the dynamic menu categories in a sub-menu
+        sub_menu = WidgetSubMenuBar(host, vertical=True)
+        try:
             parent.addMenus(sub_menu)
+        except (AttributeError, TypeError): # FIXME: pyjamas can throw a TypeError depending on compilation options
+            pass
+        else:
             if len(sub_menu.getCategories()) > 0:
                 self.addCategory('', '', 'plugins', sub_menu)