Show More
@@ -100,7 +100,7 b' class Widget(LoggingConfigurable):' | |||
|
100 | 100 | registered in the front-end to create and sync this widget with.""") |
|
101 | 101 | _view_name = Unicode(help="""Default view registered in the front-end |
|
102 | 102 | to use to represent the widget.""", sync=True) |
|
103 |
|
|
|
103 | comm = Instance('IPython.kernel.comm.Comm') | |
|
104 | 104 | |
|
105 | 105 | msg_throttle = Int(3, sync=True, help="""Maximum number of msgs the |
|
106 | 106 | front-end can send before receiving an idle msg from the back-end.""") |
@@ -133,20 +133,12 b' class Widget(LoggingConfigurable):' | |||
|
133 | 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 | 136 | def open(self): |
|
145 | 137 | """Open a comm to the frontend if one isn't already open.""" |
|
146 |
if self. |
|
|
138 | if self.comm is None: | |
|
147 | 139 | # Create a comm. |
|
148 |
self. |
|
|
149 |
self. |
|
|
140 | self.comm = Comm(target_name=self._model_name) | |
|
141 | self.comm.on_msg(self._handle_msg) | |
|
150 | 142 | Widget.widgets[self.model_id] = self |
|
151 | 143 | |
|
152 | 144 | # first update |
@@ -169,10 +161,10 b' class Widget(LoggingConfigurable):' | |||
|
169 | 161 | Closes the underlying comm. |
|
170 | 162 | When the comm is closed, all of the widget views are automatically |
|
171 | 163 | removed from the front-end.""" |
|
172 |
if self. |
|
|
164 | if self.comm is not None: | |
|
173 | 165 | Widget.widgets.pop(self.model_id, None) |
|
174 |
self. |
|
|
175 |
self. |
|
|
166 | self.comm.close() | |
|
167 | self.comm = None | |
|
176 | 168 | |
|
177 | 169 | def send_state(self, key=None): |
|
178 | 170 | """Sends the widget state, or a piece of it, to the front-end. |
@@ -393,7 +385,10 b' class DOMWidget(Widget):' | |||
|
393 | 385 | selector: unicode (optional, kwarg only) |
|
394 | 386 | JQuery selector to use to apply the CSS key/value. If no selector |
|
395 | 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 | 393 | if value is None: |
|
399 | 394 | css_dict = dict_or_key |
General Comments 0
You need to be logged in to leave comments.
Login now