2013-10-26 02:31:48 +08:00
|
|
|
"""ContainerWidget class.
|
|
|
|
|
|
|
|
Represents a container that can be used to group other widgets.
|
|
|
|
"""
|
2014-06-10 04:38:44 +08:00
|
|
|
|
|
|
|
# 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
|
2014-02-26 11:08:43 +08:00
|
|
|
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)
|
2013-10-22 00:55:49 +08:00
|
|
|
|
2014-02-26 11:08:43 +08:00
|
|
|
# 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)
|
2014-02-24 02:57:07 +08:00
|
|
|
|
2014-07-18 04:07:37 +08:00
|
|
|
def __init__(self, children = None, **kwargs):
|
|
|
|
kwargs['children'] = children
|
2014-02-24 02:57:07 +08:00
|
|
|
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:
|
2014-02-24 02:57:07 +08:00
|
|
|
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)
|
2014-01-16 22:48:56 +08:00
|
|
|
|
|
|
|
description = Unicode(sync=True)
|
|
|
|
button_text = Unicode(sync=True)
|