@ -100,7 +100,7 @@ class Widget(LoggingConfigurable):
registered in the front - end to create and sync this widget with . """ )
_view_name = Unicode ( help = """ Default view registered in the front-end
to use to represent the widget . """ , sync=True)
_ comm = Instance ( ' IPython.kernel.comm.Comm ' )
comm = Instance ( ' IPython.kernel.comm.Comm ' )
msg_throttle = Int ( 3 , sync = True , help = """ Maximum number of msgs the
front - end can send before receiving an idle msg from the back - end . """ )
@ -133,20 +133,12 @@ class Widget(LoggingConfigurable):
# Properties
#-------------------------------------------------------------------------
@property
def comm ( self ) :
""" Gets the Comm associated with this widget.
If a Comm doesn ' t exist yet, a Comm will be created automagically. " " "
self . open ( )
return self . _comm
def open ( self ) :
""" Open a comm to the frontend if one isn ' t already open. """
if self . _ comm is None :
if self . comm is None :
# Create a comm.
self . _ comm = Comm ( target_name = self . _model_name )
self . _ comm. on_msg ( self . _handle_msg )
self . comm = Comm ( target_name = self . _model_name )
self . comm . on_msg ( self . _handle_msg )
Widget . widgets [ self . model_id ] = self
# first update
@ -169,10 +161,10 @@ class Widget(LoggingConfigurable):
Closes the underlying comm .
When the comm is closed , all of the widget views are automatically
removed from the front - end . """
if self . _ comm is not None :
if self . comm is not None :
Widget . widgets . pop ( self . model_id , None )
self . _ comm. close ( )
self . _ comm = None
self . comm. close ( )
self . comm = None
def send_state ( self , key = None ) :
""" Sends the widget state, or a piece of it, to the front-end.
@ -393,7 +385,10 @@ class DOMWidget(Widget):
selector : unicode ( optional , kwarg only )
JQuery selector to use to apply the CSS key / value . If no selector
is provided , an empty selector is used . An empty selector makes the
front - end try to apply the css to the top - level element .
front - end try to apply the css to a default element . The default
element is an attribute unique to each view , which is a DOM element
of the view that should be styled with common CSS ( see
` $ el_to_style ` in the Javascript code ) .
"""
if value is None :
css_dict = dict_or_key