widget_container.py
33 lines
| 1.0 KiB
| text/x-python
|
PythonLexer
Jonathan Frederic
|
r14283 | """ContainerWidget class. | ||
Represents a container that can be used to group other widgets. | ||||
""" | ||||
Jonathan Frederic
|
r17172 | |||
# Copyright (c) IPython Development Team. | ||||
Jonathan Frederic
|
r14283 | # Distributed under the terms of the Modified BSD License. | ||
Jonathan Frederic
|
r14540 | from .widget import DOMWidget | ||
MinRK
|
r15480 | from IPython.utils.traitlets import Unicode, Tuple, TraitError | ||
Jonathan Frederic
|
r14239 | |||
Jonathan Frederic
|
r14540 | class ContainerWidget(DOMWidget): | ||
Jonathan Frederic
|
r14701 | _view_name = Unicode('ContainerView', sync=True) | ||
Jonathan Frederic
|
r14268 | |||
MinRK
|
r15480 | # Child widgets in the container. | ||
# Using a tuple here to force reassignment to update the list. | ||||
# When a proper notifying-list trait exists, that is what should be used here. | ||||
Jonathan Frederic
|
r17173 | children = Tuple(sync=True) | ||
zah
|
r15446 | |||
def __init__(self, **kwargs): | ||||
super(ContainerWidget, self).__init__(**kwargs) | ||||
self.on_displayed(ContainerWidget._fire_children_displayed) | ||||
def _fire_children_displayed(self): | ||||
Jonathan Frederic
|
r17173 | for child in self.children: | ||
zah
|
r15446 | child._handle_displayed() | ||
Jonathan Frederic
|
r14607 | |||
Jonathan Frederic
|
r14676 | class PopupWidget(ContainerWidget): | ||
Jonathan Frederic
|
r14701 | _view_name = Unicode('PopupView', sync=True) | ||
Jonathan Frederic
|
r14608 | |||
description = Unicode(sync=True) | ||||
button_text = Unicode(sync=True) | ||||