/usr/lib/python2.7/dist-packages/ipywidgets/widgets/widget_box.py is in python-ipywidgets 5.2.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | """Box class.
Represents a container that can be used to group other widgets.
"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from .domwidget import DOMWidget
from .widget import Widget, register, widget_serialization
from traitlets import Unicode, Tuple, Int, CaselessStrEnum, Instance
from warnings import warn
@register('Jupyter.Box')
class Box(DOMWidget):
"""Displays multiple widgets in a group."""
_model_module = Unicode('jupyter-js-widgets').tag(sync=True)
_view_module = Unicode('jupyter-js-widgets').tag(sync=True)
_model_name = Unicode('BoxModel').tag(sync=True)
_view_name = Unicode('BoxView').tag(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.
children = Tuple().tag(sync=True, **widget_serialization)
_overflow_values = ['visible', 'hidden', 'scroll', 'auto', 'initial', 'inherit', '']
overflow_x = CaselessStrEnum(
values=_overflow_values,
default_value='', help="""Specifies what happens to content that is too
large for the rendered region.""").tag(sync=True)
overflow_y = CaselessStrEnum(
values=_overflow_values,
default_value='', help="""Specifies what happens to content that is too
large for the rendered region.""").tag(sync=True)
box_style = CaselessStrEnum(
values=['success', 'info', 'warning', 'danger', ''], default_value='',
help="""Use a predefined styling for the box.""").tag(sync=True)
def __init__(self, children = (), **kwargs):
kwargs['children'] = children
super(Box, self).__init__(**kwargs)
self.on_displayed(Box._fire_children_displayed)
def _fire_children_displayed(self):
for child in self.children:
child._handle_displayed()
@register('Jupyter.Proxy')
class Proxy(DOMWidget):
"""A DOMWidget that holds another DOMWidget or nothing."""
_model_module = Unicode('jupyter-js-widgets').tag(sync=True)
_view_module = Unicode('jupyter-js-widgets').tag(sync=True)
_model_name = Unicode('ProxyModel').tag(sync=True)
_view_name = Unicode('ProxyView').tag(sync=True)
# Child widget of the Proxy
child = Instance(DOMWidget, allow_none=True).tag(sync=True, **widget_serialization)
def __init__(self, child, **kwargs):
kwargs['child'] = child
super(Proxy, self).__init__(**kwargs)
self.on_displayed(Proxy._fire_child_displayed)
def _fire_child_displayed(self):
if self.child is not None:
self.child._handle_displayed()
@register('Jupyter.PlaceProxy')
class PlaceProxy(Proxy):
"""Renders the child widget at the specified selector."""
_view_name = Unicode('PlaceProxyView').tag(sync=True)
_model_name = Unicode('PlaceProxyModel').tag(sync=True)
selector = Unicode().tag(sync=True)
def VBox(*pargs, **kwargs):
"""Displays multiple widgets vertically using the flexible box model."""
box = Box(*pargs, **kwargs)
box.layout.display = 'flex'
box.layout.flex_flow = 'column'
box.layout.align_items = 'stretch'
return box
def HBox(*pargs, **kwargs):
"""Displays multiple widgets horizontally using the flexible box model."""
box = Box(*pargs, **kwargs)
box.layout.display = 'flex'
box.layout.align_items = 'stretch'
return box
@register('Jupyter.FlexBox')
class FlexBox(Box): # TODO: Deprecated in 5.0 (entire class)
"""Displays multiple widgets using the flexible box model."""
_view_name = Unicode('FlexBoxView').tag(sync=True)
_model_name = Unicode('FlexBoxModel').tag(sync=True)
orientation = CaselessStrEnum(values=['vertical', 'horizontal'], default_value='vertical').tag(sync=True)
flex = Int(help="""Specify the flexible-ness of the model.""").tag(sync=True)
def _flex_changed(self, name, old, new):
new = min(max(0, new), 2)
if self.flex != new:
self.flex = new
_locations = ['start', 'center', 'end', 'baseline', 'stretch']
pack = CaselessStrEnum(values=_locations, default_value='start').tag(sync=True)
align = CaselessStrEnum(values=_locations, default_value='start').tag( sync=True)
def __init__(self, *pargs, **kwargs):
warn('FlexBox is deprecated in ipywidgets 5.0. Use Box and Box.layout instead.', DeprecationWarning)
super(FlexBox, self).__init__(*pargs, **kwargs)
|