Show More
@@ -176,13 +176,15 b' class Widget(LoggingConfigurable):' | |||
|
176 | 176 | self._comm = None |
|
177 | 177 | |
|
178 | 178 | |
|
179 | def _handle_displayed(self, view_name): | |
|
179 | def _handle_displayed(self, view_name, parent=None): | |
|
180 | 180 | """Called when a view has been displayed for this widget instance |
|
181 | 181 | |
|
182 | 182 | Parameters |
|
183 | 183 | ---------- |
|
184 | 184 | view_name: unicode |
|
185 |
Name of the view that was displayed. |
|
|
185 | Name of the view that was displayed. | |
|
186 | parent: Widget instance [optional] | |
|
187 | Widget that this widget should be displayed as a child of.""" | |
|
186 | 188 | for handler in self._display_callbacks: |
|
187 | 189 | if callable(handler): |
|
188 | 190 | argspec = inspect.getargspec(handler) |
@@ -199,6 +201,8 b' class Widget(LoggingConfigurable):' | |||
|
199 | 201 | handler(self) |
|
200 | 202 | elif nargs == 2: |
|
201 | 203 | handler(self, view_name) |
|
204 | elif nargs == 3: | |
|
205 | handler(self, view_name, parent) | |
|
202 | 206 | else: |
|
203 | 207 | raise TypeError('Widget display callback must ' \ |
|
204 | 208 | 'accept 0-2 arguments, not %d.' % nargs) |
@@ -371,6 +375,7 b' class Widget(LoggingConfigurable):' | |||
|
371 | 375 | - callback() |
|
372 | 376 | - callback(sender) |
|
373 | 377 | - callback(sender, view_name) |
|
378 | - callback(sender, view_name, parent) | |
|
374 | 379 | remove: bool |
|
375 | 380 | True if the callback should be unregistered.""" |
|
376 | 381 | if remove and callback in self._display_callbacks: |
@@ -403,12 +408,13 b' class Widget(LoggingConfigurable):' | |||
|
403 | 408 | # Show view. |
|
404 | 409 | if self.parent is None or self.parent._comm is None: |
|
405 | 410 | self._comm.send({"method": "display", "view_name": view_name}) |
|
411 | self._handle_displayed(view_name) | |
|
406 | 412 | else: |
|
407 | 413 | self._comm.send({"method": "display", |
|
408 | 414 | "view_name": view_name, |
|
409 | 415 | "parent": self.parent._comm.comm_id}) |
|
416 | self._handle_displayed(view_name, self.parent) | |
|
410 | 417 | self._displayed = True |
|
411 | self._handle_displayed(view_name) | |
|
412 | 418 | |
|
413 | 419 | # Now display children if any. |
|
414 | 420 | for child in self._children: |
General Comments 0
You need to be logged in to leave comments.
Login now