##// END OF EJS Templates
Added event for widget construction
Jonathan Frederic -
Show More
@@ -32,10 +32,24 b' from IPython.utils.py3compat import string_types'
32 32 #-----------------------------------------------------------------------------
33 33 class Widget(LoggingConfigurable):
34 34
35 # Shared declarations
35 # Shared declarations (Class level)
36 36 _keys = []
37 widget_construction_callback = None
38
39 def on_widget_constructed(callback):
40 """Class method, registers a callback to be called when a widget is
41 constructed. The callback must have the following signature:
42 callback(widget)"""
43 Widget.widget_construction_callback = callback
44
45 def _handle_widget_constructed(widget):
46 """Class method, called when a widget is constructed."""
47 if Widget.widget_construction_callback is not None and callable(Widget.widget_construction_callback):
48 Widget.widget_construction_callback(widget)
49
37 50
38 # Public declarations
51
52 # Public declarations (Instance level)
39 53 target_name = Unicode('widget', help="""Name of the backbone model
40 54 registered in the frontend to create and sync this widget with.""")
41 55 default_view_name = Unicode(help="""Default view registered in the frontend
@@ -83,6 +97,8 b' class Widget(LoggingConfigurable):'
83 97
84 98 # Register after init to allow default values to be specified
85 99 self.on_trait_change(self._handle_property_changed, self.keys)
100
101 Widget._handle_widget_constructed(self)
86 102
87 103
88 104 def __del__(self):
General Comments 0
You need to be logged in to leave comments. Login now