##// END OF EJS Templates
Saving files works
Saving files works

File last commit:

r18533:b46a0ee8
r19012:08916002
Show More
widget_box.py
91 lines | 3.2 KiB | text/x-python | PythonLexer
Jonathan Frederic
s/Container/Box
r17637 """Box class.
Jonathan Frederic
Cleaned up Python widget code.
r14283
Represents a container that can be used to group other widgets.
"""
Jonathan Frederic
Allow a widget to be displayed more than once within a parent widget.
r17172
# Copyright (c) IPython Development Team.
Jonathan Frederic
Cleaned up Python widget code.
r14283 # Distributed under the terms of the Modified BSD License.
Sylvain Corlay
registering core widgets
r18531 from .widget import DOMWidget, register
Jonathan Frederic
Embrace flexible box model
r17596 from IPython.utils.traitlets import Unicode, Tuple, TraitError, Int, CaselessStrEnum
Jonathan Frederic
Renamed *Widget to *,...
r17598 from IPython.utils.warn import DeprecatedClass
Jonathan Frederic
Add container widget
r14239
Sylvain Corlay
jupyter -> IPython
r18533 @register('IPython.Box')
Jonathan Frederic
s/Container/Box
r17637 class Box(DOMWidget):
Jonathan Frederic
Added some doc strings on the widgets....
r17602 """Displays multiple widgets in a group."""
Jonathan Frederic
s/Container/Box
r17637 _view_name = Unicode('BoxView', sync=True)
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268
MinRK
don't validate ContainerWidget.children...
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.
Jason Grout
Container assumes the children attribute is not None...
r17266 children = Tuple(sync=True, allow_none=False)
Jonathan Frederic
Fix some bugs found by the widget examples,...
r17727
_overflow_values = ['visible', 'hidden', 'scroll', 'auto', 'initial', 'inherit', '']
overflow_x = CaselessStrEnum(
values=_overflow_values,
default_value='', allow_none=False, sync=True, help="""Specifies what
happens to content that is too large for the rendered region.""")
overflow_y = CaselessStrEnum(
values=_overflow_values,
default_value='', allow_none=False, sync=True, help="""Specifies what
happens to content that is too large for the rendered region.""")
zah
Children fire event...
r15446
Jonathan Frederic
Added Bootstrap specific classes,...
r17728 box_style = CaselessStrEnum(
values=['success', 'info', 'warning', 'danger', ''],
default_value='', allow_none=True, sync=True, help="""Use a
predefined styling for the box.""")
Jason Grout
Container assumes the children attribute is not None...
r17266 def __init__(self, children = (), **kwargs):
Jason Grout
Make Container widgets take children as the first positional argument...
r17261 kwargs['children'] = children
Jonathan Frederic
s/Container/Box
r17637 super(Box, self).__init__(**kwargs)
self.on_displayed(Box._fire_children_displayed)
zah
Children fire event...
r15446
def _fire_children_displayed(self):
Jonathan Frederic
Fixed buggy behavior
r17173 for child in self.children:
zah
Children fire event...
r15446 child._handle_displayed()
Jonathan Frederic
More PEP8 changes
r14607
Sylvain Corlay
jupyter -> IPython
r18533 @register('IPython.Popup')
Jonathan Frederic
s/Container/Box
r17637 class Popup(Box):
Jonathan Frederic
Added some doc strings on the widgets....
r17602 """Displays multiple widgets in an in page popup div."""
Jonathan Frederic
s/view_name/_view_name
r14701 _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)
Jonathan Frederic
Embrace flexible box model
r17596
Sylvain Corlay
jupyter -> IPython
r18533 @register('IPython.FlexBox')
Jonathan Frederic
s/Container/Box
r17637 class FlexBox(Box):
Jonathan Frederic
Added some doc strings on the widgets....
r17602 """Displays multiple widgets using the flexible box model."""
Jonathan Frederic
s/Container/Box
r17637 _view_name = Unicode('FlexBoxView', sync=True)
Jonathan Frederic
Make HBox and VBox helper functions
r17601 orientation = CaselessStrEnum(values=['vertical', 'horizontal'], default_value='vertical', sync=True)
Jonathan Frederic
Embrace flexible box model
r17596 flex = Int(0, sync=True, help="""Specify the flexible-ness of the model.""")
def _flex_changed(self, name, old, new):
new = min(max(0, new), 2)
if self.flex != new:
self.flex = new
Jonathan Frederic
Added baseline and stretch
r17597 _locations = ['start', 'center', 'end', 'baseline', 'stretch']
pack = CaselessStrEnum(
values=_locations,
default_value='start', allow_none=False, sync=True)
align = CaselessStrEnum(
values=_locations,
default_value='start', allow_none=False, sync=True)
Jonathan Frederic
Embrace flexible box model
r17596
Jonathan Frederic
Make HBox and VBox helper functions
r17601 def VBox(*pargs, **kwargs):
Jonathan Frederic
Added some doc strings on the widgets....
r17602 """Displays multiple widgets vertically using the flexible box model."""
Jonathan Frederic
Make HBox and VBox helper functions
r17601 kwargs['orientation'] = 'vertical'
Jonathan Frederic
s/Container/Box
r17637 return FlexBox(*pargs, **kwargs)
Jonathan Frederic
Embrace flexible box model
r17596
Jonathan Frederic
Make HBox and VBox helper functions
r17601 def HBox(*pargs, **kwargs):
Jonathan Frederic
Added some doc strings on the widgets....
r17602 """Displays multiple widgets horizontally using the flexible box model."""
Jonathan Frederic
Make HBox and VBox helper functions
r17601 kwargs['orientation'] = 'horizontal'
Jonathan Frederic
s/Container/Box
r17637 return FlexBox(*pargs, **kwargs)
Jonathan Frederic
Embrace flexible box model
r17596
Jonathan Frederic
Renamed *Widget to *,...
r17598
Jonathan Frederic
Added some doc strings on the widgets....
r17602 # Remove in IPython 4.0
Jonathan Frederic
s/Container/Box
r17637 ContainerWidget = DeprecatedClass(Box, 'ContainerWidget')
Jonathan Frederic
Renamed *Widget to *,...
r17598 PopupWidget = DeprecatedClass(Popup, 'PopupWidget')