##// END OF EJS Templates
Float widget views now inherit from int counterparts
Float widget views now inherit from int counterparts

File last commit:

r14676:25a9d02e
r14694:2af96a67
Show More
widget_container.py
52 lines | 1.9 KiB | text/x-python | PythonLexer
Jonathan Frederic
Cleaned up Python widget code.
r14283 """ContainerWidget class.
Represents a container that can be used to group other widgets.
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Jonathan Frederic
s/Widget/DOMWidget s/BaseWidget/Widget
r14540 from .widget import DOMWidget
Jason Grout
Intermediate changes to javascript side of backbone widgets
r14486 from IPython.utils.traitlets import Unicode, Bool, List, Instance
Jonathan Frederic
Add container widget
r14239
Jonathan Frederic
Cleaned up Python widget code.
r14283 #-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
Jonathan Frederic
s/Widget/DOMWidget s/BaseWidget/Widget
r14540 class ContainerWidget(DOMWidget):
Jonathan Frederic
Added sync=True to all view name attrs
r14590 view_name = Unicode('ContainerView', sync=True)
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268
Jonathan Frederic
Cleaned up Python widget code.
r14283 # Keys, all private and managed by helper methods. Flexible box model
# classes...
Jonathan Frederic
containers and selectioncontainers now only allow one of any single child
r14608 children = List(Instance(DOMWidget))
_children = List(Instance(DOMWidget), sync=True)
def __init__(self, *pargs, **kwargs):
"""Constructor"""
DOMWidget.__init__(self, *pargs, **kwargs)
self.on_trait_change(self._validate, ['children'])
def _validate(self, name, old, new):
"""Validate children list.
Makes sure only one instance of any given model can exist in the
children list."""
if new is not None and isinstance(new, list):
children = []
for child in new:
if child not in children:
children.append(child)
self._children = children
Jonathan Frederic
1-to-1 widget / view mapping
r14592
Jonathan Frederic
More PEP8 changes
r14607
Jonathan Frederic
s/ModalView/PopupView
r14676 class PopupWidget(ContainerWidget):
view_name = Unicode('PopupView', sync=True)
Jonathan Frederic
containers and selectioncontainers now only allow one of any single child
r14608
description = Unicode(sync=True)
button_text = Unicode(sync=True)