diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py index 456133d55..417acd714 100644 --- a/IPython/html/widgets/widget.py +++ b/IPython/html/widgets/widget.py @@ -292,6 +292,13 @@ class Widget(LoggingConfigurable): True if the callback should be unregistered.""" self._display_callbacks.register_callback(callback, remove=remove) + def add_trait(self, traitname, trait): + """Dynamically add a trait attribute to the Widget.""" + super(Widget, self).add_trait(traitname, trait) + if trait.get_metadata('sync'): + self.keys.append(traitname) + self.send_state(traitname) + #------------------------------------------------------------------------- # Support methods #-------------------------------------------------------------------------