notebook/IPython/html/widgets/widget_container.py

35 lines
1.1 KiB
Python
Raw Normal View History

2013-10-26 02:31:48 +08:00
"""ContainerWidget class.
Represents a container that can be used to group other widgets.
"""
# Copyright (c) IPython Development Team.
2013-10-26 02:31:48 +08:00
# Distributed under the terms of the Modified BSD License.
2014-01-07 20:04:24 +08:00
from .widget import DOMWidget
from IPython.utils.traitlets import Unicode, Tuple, TraitError
2013-10-17 14:15:24 +08:00
2014-01-07 20:04:24 +08:00
class ContainerWidget(DOMWidget):
2014-01-23 08:21:00 +08:00
_view_name = Unicode('ContainerView', sync=True)
# 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.
2014-06-11 00:57:50 +08:00
children = Tuple(sync=True)
def __init__(self, children = None, **kwargs):
kwargs['children'] = children
super(ContainerWidget, self).__init__(**kwargs)
self.on_displayed(ContainerWidget._fire_children_displayed)
def _fire_children_displayed(self):
2014-06-11 00:57:50 +08:00
for child in self.children:
child._handle_displayed()
2014-01-16 22:20:04 +08:00
2014-01-22 09:09:49 +08:00
class PopupWidget(ContainerWidget):
2014-01-23 08:21:00 +08:00
_view_name = Unicode('PopupView', sync=True)
description = Unicode(sync=True)
button_text = Unicode(sync=True)