Show More
@@ -100,7 +100,7 b' class Widget(LoggingConfigurable):' | |||||
100 | registered in the front-end to create and sync this widget with.""") |
|
100 | registered in the front-end to create and sync this widget with.""") | |
101 | _view_name = Unicode(help="""Default view registered in the front-end |
|
101 | _view_name = Unicode(help="""Default view registered in the front-end | |
102 | to use to represent the widget.""", sync=True) |
|
102 | to use to represent the widget.""", sync=True) | |
103 |
|
|
103 | comm = Instance('IPython.kernel.comm.Comm') | |
104 |
|
104 | |||
105 | msg_throttle = Int(3, sync=True, help="""Maximum number of msgs the |
|
105 | msg_throttle = Int(3, sync=True, help="""Maximum number of msgs the | |
106 | front-end can send before receiving an idle msg from the back-end.""") |
|
106 | front-end can send before receiving an idle msg from the back-end.""") | |
@@ -133,20 +133,12 b' class Widget(LoggingConfigurable):' | |||||
133 | # Properties |
|
133 | # Properties | |
134 | #------------------------------------------------------------------------- |
|
134 | #------------------------------------------------------------------------- | |
135 |
|
135 | |||
136 | @property |
|
|||
137 | def comm(self): |
|
|||
138 | """Gets the Comm associated with this widget. |
|
|||
139 |
|
||||
140 | If a Comm doesn't exist yet, a Comm will be created automagically.""" |
|
|||
141 | self.open() |
|
|||
142 | return self._comm |
|
|||
143 |
|
||||
144 | def open(self): |
|
136 | def open(self): | |
145 | """Open a comm to the frontend if one isn't already open.""" |
|
137 | """Open a comm to the frontend if one isn't already open.""" | |
146 |
if self. |
|
138 | if self.comm is None: | |
147 | # Create a comm. |
|
139 | # Create a comm. | |
148 |
self. |
|
140 | self.comm = Comm(target_name=self._model_name) | |
149 |
self. |
|
141 | self.comm.on_msg(self._handle_msg) | |
150 | Widget.widgets[self.model_id] = self |
|
142 | Widget.widgets[self.model_id] = self | |
151 |
|
143 | |||
152 | # first update |
|
144 | # first update | |
@@ -169,10 +161,10 b' class Widget(LoggingConfigurable):' | |||||
169 | Closes the underlying comm. |
|
161 | Closes the underlying comm. | |
170 | When the comm is closed, all of the widget views are automatically |
|
162 | When the comm is closed, all of the widget views are automatically | |
171 | removed from the front-end.""" |
|
163 | removed from the front-end.""" | |
172 |
if self. |
|
164 | if self.comm is not None: | |
173 | Widget.widgets.pop(self.model_id, None) |
|
165 | Widget.widgets.pop(self.model_id, None) | |
174 |
self. |
|
166 | self.comm.close() | |
175 |
self. |
|
167 | self.comm = None | |
176 |
|
168 | |||
177 | def send_state(self, key=None): |
|
169 | def send_state(self, key=None): | |
178 | """Sends the widget state, or a piece of it, to the front-end. |
|
170 | """Sends the widget state, or a piece of it, to the front-end. | |
@@ -393,7 +385,10 b' class DOMWidget(Widget):' | |||||
393 | selector: unicode (optional, kwarg only) |
|
385 | selector: unicode (optional, kwarg only) | |
394 | JQuery selector to use to apply the CSS key/value. If no selector |
|
386 | JQuery selector to use to apply the CSS key/value. If no selector | |
395 | is provided, an empty selector is used. An empty selector makes the |
|
387 | is provided, an empty selector is used. An empty selector makes the | |
396 |
front-end try to apply the css to |
|
388 | front-end try to apply the css to a default element. The default | |
|
389 | element is an attribute unique to each view, which is a DOM element | |||
|
390 | of the view that should be styled with common CSS (see | |||
|
391 | `$el_to_style` in the Javascript code). | |||
397 | """ |
|
392 | """ | |
398 | if value is None: |
|
393 | if value is None: | |
399 | css_dict = dict_or_key |
|
394 | css_dict = dict_or_key |
General Comments 0
You need to be logged in to leave comments.
Login now