comparison src/browser/sat_browser/base_menu.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 a5019e62c3e9
children 6d3142b782c3
comparison
equal deleted inserted replaced
631:e287a4b431c1 632:c2abadf31afb
35 from pyjamas import Window 35 from pyjamas import Window
36 36
37 import re 37 import re
38 38
39 39
40 class MenuCmd: 40 class MenuCmd(object):
41 """Return an object with an "execute" method that can be set to a menu item callback""" 41 """Return an object with an "execute" method that can be set to a menu item callback"""
42 42
43 def __init__(self, object_, handler=None, data=None): 43 def __init__(self, object_, handler=None, data=None):
44 """ 44 """
45 @param object_ (object): a callable or a class instance 45 @param object_ (object): a callable or a class instance
56 def execute(self): 56 def execute(self):
57 log.debug("execute %s" % self.callback) 57 log.debug("execute %s" % self.callback)
58 self.callback(self.data) if self.data else self.callback() 58 self.callback(self.data) if self.data else self.callback()
59 59
60 60
61 class PluginMenuCmd: 61 class PluginMenuCmd(object):
62 """Like MenuCmd, but instead of executing a method, it will command the bridge to launch an action""" 62 """Like MenuCmd, but instead of executing a method, it will command the bridge to launch an action"""
63 63
64 def __init__(self, host, action_id, menu_data=None): 64 def __init__(self, host, action_id, menu_data=None):
65 self.host = host 65 self.host = host
66 self.action_id = action_id 66 self.action_id = action_id