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