##// END OF EJS Templates
Merge pull request #6153 from jasongrout/container-children-arg...
Jonathan Frederic -
r17285:d6d4f536 merge
parent child Browse files
Show More
@@ -1,33 +1,34 b''
1 """ContainerWidget class.
1 """ContainerWidget class.
2
2
3 Represents a container that can be used to group other widgets.
3 Represents a container that can be used to group other widgets.
4 """
4 """
5
5
6 # Copyright (c) IPython Development Team.
6 # Copyright (c) IPython Development Team.
7 # Distributed under the terms of the Modified BSD License.
7 # Distributed under the terms of the Modified BSD License.
8
8
9 from .widget import DOMWidget
9 from .widget import DOMWidget
10 from IPython.utils.traitlets import Unicode, Tuple, TraitError
10 from IPython.utils.traitlets import Unicode, Tuple, TraitError
11
11
12 class ContainerWidget(DOMWidget):
12 class ContainerWidget(DOMWidget):
13 _view_name = Unicode('ContainerView', sync=True)
13 _view_name = Unicode('ContainerView', sync=True)
14
14
15 # Child widgets in the container.
15 # Child widgets in the container.
16 # Using a tuple here to force reassignment to update the list.
16 # Using a tuple here to force reassignment to update the list.
17 # When a proper notifying-list trait exists, that is what should be used here.
17 # When a proper notifying-list trait exists, that is what should be used here.
18 children = Tuple(sync=True)
18 children = Tuple(sync=True, allow_none=False)
19
19
20 def __init__(self, **kwargs):
20 def __init__(self, children = (), **kwargs):
21 kwargs['children'] = children
21 super(ContainerWidget, self).__init__(**kwargs)
22 super(ContainerWidget, self).__init__(**kwargs)
22 self.on_displayed(ContainerWidget._fire_children_displayed)
23 self.on_displayed(ContainerWidget._fire_children_displayed)
23
24
24 def _fire_children_displayed(self):
25 def _fire_children_displayed(self):
25 for child in self.children:
26 for child in self.children:
26 child._handle_displayed()
27 child._handle_displayed()
27
28
28
29
29 class PopupWidget(ContainerWidget):
30 class PopupWidget(ContainerWidget):
30 _view_name = Unicode('PopupView', sync=True)
31 _view_name = Unicode('PopupView', sync=True)
31
32
32 description = Unicode(sync=True)
33 description = Unicode(sync=True)
33 button_text = Unicode(sync=True)
34 button_text = Unicode(sync=True)
General Comments 0
You need to be logged in to leave comments. Login now