Show More
@@ -14,11 +14,10 b' from .interaction import interact, interactive, fixed' | |||||
14 | # Deprecated classes |
|
14 | # Deprecated classes | |
15 | from .widget_bool import CheckboxWidget, ToggleButtonWidget |
|
15 | from .widget_bool import CheckboxWidget, ToggleButtonWidget | |
16 | from .widget_button import ButtonWidget |
|
16 | from .widget_button import ButtonWidget | |
17 |
from .widget_container import ContainerWidget, |
|
17 | from .widget_container import ContainerWidget, PopupWidget | |
18 | from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget |
|
18 | from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget | |
19 | from .widget_image import ImageWidget |
|
19 | from .widget_image import ImageWidget | |
20 | from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget |
|
20 | from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget | |
21 | from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget |
|
21 | from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget | |
22 | from .widget_selectioncontainer import TabWidget, AccordionWidget |
|
22 | from .widget_selectioncontainer import TabWidget, AccordionWidget | |
23 | from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget |
|
23 | from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget | |
24 | from .interaction import interact, interactive, fixed |
|
@@ -21,17 +21,23 b' from IPython.utils.warn import DeprecatedClass' | |||||
21 | # Classes |
|
21 | # Classes | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 | class _Bool(DOMWidget): |
|
23 | class _Bool(DOMWidget): | |
|
24 | """A base class for creating widgets that represent booleans.""" | |||
24 | value = Bool(False, help="Bool value", sync=True) |
|
25 | value = Bool(False, help="Bool value", sync=True) | |
25 |
description = Unicode('', help="Description of the boolean (label).", sync=True) |
|
26 | description = Unicode('', help="Description of the boolean (label).", sync=True) | |
26 | disabled = Bool(False, help="Enable or disable user changes.", sync=True) |
|
27 | disabled = Bool(False, help="Enable or disable user changes.", sync=True) | |
27 |
|
28 | |||
28 |
|
29 | |||
29 | class Checkbox(_Bool): |
|
30 | class Checkbox(_Bool): | |
|
31 | """Displays a boolean `value`.""" | |||
30 | _view_name = Unicode('CheckboxView', sync=True) |
|
32 | _view_name = Unicode('CheckboxView', sync=True) | |
31 |
|
33 | |||
32 |
|
34 | |||
33 | class ToggleButton(_Bool): |
|
35 | class ToggleButton(_Bool): | |
34 | _view_name = Unicode('ToggleButtonView', sync=True) |
|
36 | """Displays a boolean `value`.""" | |
35 |
|
37 | |||
|
38 | _view_name = Unicode('ToggleButtonView', sync=True) | |||
|
39 | ||||
|
40 | ||||
|
41 | # Remove in IPython 4.0 | |||
36 | CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget') |
|
42 | CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget') | |
37 | ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget') |
|
43 | ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget') |
@@ -22,6 +22,10 b' from IPython.utils.warn import DeprecatedClass' | |||||
22 | # Classes |
|
22 | # Classes | |
23 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
24 | class Button(DOMWidget): |
|
24 | class Button(DOMWidget): | |
|
25 | """Button widget. | |||
|
26 | ||||
|
27 | This widget has an `on_click` method that allows you to listen for the | |||
|
28 | user clicking on the button. The click event itself is stateless.""" | |||
25 | _view_name = Unicode('ButtonView', sync=True) |
|
29 | _view_name = Unicode('ButtonView', sync=True) | |
26 |
|
30 | |||
27 | # Keys |
|
31 | # Keys | |
@@ -56,5 +60,6 b' class Button(DOMWidget):' | |||||
56 | if content.get('event', '') == 'click': |
|
60 | if content.get('event', '') == 'click': | |
57 | self._click_handlers(self) |
|
61 | self._click_handlers(self) | |
58 |
|
62 | |||
59 |
|
63 | |||
|
64 | # Remove in IPython 4.0 | |||
60 | ButtonWidget = DeprecatedClass(Button, 'ButtonWidget') |
|
65 | ButtonWidget = DeprecatedClass(Button, 'ButtonWidget') |
@@ -11,6 +11,7 b' from IPython.utils.traitlets import Unicode, Tuple, TraitError, Int, CaselessStr' | |||||
11 | from IPython.utils.warn import DeprecatedClass |
|
11 | from IPython.utils.warn import DeprecatedClass | |
12 |
|
12 | |||
13 | class Container(DOMWidget): |
|
13 | class Container(DOMWidget): | |
|
14 | """Displays multiple widgets in a group.""" | |||
14 | _view_name = Unicode('ContainerView', sync=True) |
|
15 | _view_name = Unicode('ContainerView', sync=True) | |
15 |
|
16 | |||
16 | # Child widgets in the container. |
|
17 | # Child widgets in the container. | |
@@ -29,6 +30,7 b' class Container(DOMWidget):' | |||||
29 |
|
30 | |||
30 |
|
31 | |||
31 | class Popup(Container): |
|
32 | class Popup(Container): | |
|
33 | """Displays multiple widgets in an in page popup div.""" | |||
32 | _view_name = Unicode('PopupView', sync=True) |
|
34 | _view_name = Unicode('PopupView', sync=True) | |
33 |
|
35 | |||
34 | description = Unicode(sync=True) |
|
36 | description = Unicode(sync=True) | |
@@ -36,6 +38,7 b' class Popup(Container):' | |||||
36 |
|
38 | |||
37 |
|
39 | |||
38 | class FlexContainer(Container): |
|
40 | class FlexContainer(Container): | |
|
41 | """Displays multiple widgets using the flexible box model.""" | |||
39 | _view_name = Unicode('FlexContainerView', sync=True) |
|
42 | _view_name = Unicode('FlexContainerView', sync=True) | |
40 | orientation = CaselessStrEnum(values=['vertical', 'horizontal'], default_value='vertical', sync=True) |
|
43 | orientation = CaselessStrEnum(values=['vertical', 'horizontal'], default_value='vertical', sync=True) | |
41 | flex = Int(0, sync=True, help="""Specify the flexible-ness of the model.""") |
|
44 | flex = Int(0, sync=True, help="""Specify the flexible-ness of the model.""") | |
@@ -54,14 +57,17 b' class FlexContainer(Container):' | |||||
54 |
|
57 | |||
55 |
|
58 | |||
56 | def VBox(*pargs, **kwargs): |
|
59 | def VBox(*pargs, **kwargs): | |
|
60 | """Displays multiple widgets vertically using the flexible box model.""" | |||
57 | kwargs['orientation'] = 'vertical' |
|
61 | kwargs['orientation'] = 'vertical' | |
58 | return FlexContainer(*pargs, **kwargs) |
|
62 | return FlexContainer(*pargs, **kwargs) | |
59 |
|
63 | |||
60 | def HBox(*pargs, **kwargs): |
|
64 | def HBox(*pargs, **kwargs): | |
|
65 | """Displays multiple widgets horizontally using the flexible box model.""" | |||
61 | kwargs['orientation'] = 'horizontal' |
|
66 | kwargs['orientation'] = 'horizontal' | |
62 | return FlexContainer(*pargs, **kwargs) |
|
67 | return FlexContainer(*pargs, **kwargs) | |
63 |
|
68 | |||
64 |
|
69 | |||
|
70 | # Remove in IPython 4.0 | |||
65 | ContainerWidget = DeprecatedClass(Container, 'ContainerWidget') |
|
71 | ContainerWidget = DeprecatedClass(Container, 'ContainerWidget') | |
66 | PopupWidget = DeprecatedClass(Popup, 'PopupWidget') |
|
72 | PopupWidget = DeprecatedClass(Popup, 'PopupWidget') | |
67 |
|
73 |
@@ -61,8 +61,8 b' class FloatSlider(_BoundedFloat):' | |||||
61 | class FloatProgress(_BoundedFloat): |
|
61 | class FloatProgress(_BoundedFloat): | |
62 | _view_name = Unicode('ProgressView', sync=True) |
|
62 | _view_name = Unicode('ProgressView', sync=True) | |
63 |
|
63 | |||
64 | _FloatWidget = DeprecatedClass(_Float, '_FloatWidget') |
|
64 | ||
65 | _BoundedFloatWidget = DeprecatedClass(_BoundedFloat, '_BoundedFloatWidget') |
|
65 | # Remove in IPython 4.0 | |
66 | FloatTextWidget = DeprecatedClass(FloatText, 'FloatTextWidget') |
|
66 | FloatTextWidget = DeprecatedClass(FloatText, 'FloatTextWidget') | |
67 | BoundedFloatTextWidget = DeprecatedClass(BoundedFloatText, 'BoundedFloatTextWidget') |
|
67 | BoundedFloatTextWidget = DeprecatedClass(BoundedFloatText, 'BoundedFloatTextWidget') | |
68 | FloatSliderWidget = DeprecatedClass(FloatSlider, 'FloatSliderWidget') |
|
68 | FloatSliderWidget = DeprecatedClass(FloatSlider, 'FloatSliderWidget') |
@@ -23,6 +23,12 b' from IPython.utils.warn import DeprecatedClass' | |||||
23 | # Classes |
|
23 | # Classes | |
24 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
25 | class Image(DOMWidget): |
|
25 | class Image(DOMWidget): | |
|
26 | """Displays an image as a widget. | |||
|
27 | ||||
|
28 | The `value` of this widget accepts a byte string. The byte string is the raw | |||
|
29 | image data that you want the browser to display. You can explicitly define | |||
|
30 | the format of the byte string using the `format` trait (which defaults to | |||
|
31 | "png").""" | |||
26 | _view_name = Unicode('ImageView', sync=True) |
|
32 | _view_name = Unicode('ImageView', sync=True) | |
27 |
|
33 | |||
28 | # Define the custom state properties to sync with the front-end |
|
34 | # Define the custom state properties to sync with the front-end | |
@@ -35,4 +41,6 b' class Image(DOMWidget):' | |||||
35 | def _value_changed(self, name, old, new): |
|
41 | def _value_changed(self, name, old, new): | |
36 | self._b64value = base64.b64encode(new) |
|
42 | self._b64value = base64.b64encode(new) | |
37 |
|
43 | |||
|
44 | ||||
|
45 | # Remove in IPython 4.0 | |||
38 | ImageWidget = DeprecatedClass(Image, 'ImageWidget') |
|
46 | ImageWidget = DeprecatedClass(Image, 'ImageWidget') |
@@ -21,12 +21,15 b' from IPython.utils.warn import DeprecatedClass' | |||||
21 | # Classes |
|
21 | # Classes | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 | class _Int(DOMWidget): |
|
23 | class _Int(DOMWidget): | |
|
24 | """Base class used to create widgets that represent an int.""" | |||
24 | value = CInt(0, help="Int value", sync=True) |
|
25 | value = CInt(0, help="Int value", sync=True) | |
25 | disabled = Bool(False, help="Enable or disable user changes", sync=True) |
|
26 | disabled = Bool(False, help="Enable or disable user changes", sync=True) | |
26 | description = Unicode(help="Description of the value this widget represents", sync=True) |
|
27 | description = Unicode(help="Description of the value this widget represents", sync=True) | |
27 |
|
28 | |||
28 |
|
29 | |||
29 | class _BoundedInt(_Int): |
|
30 | class _BoundedInt(_Int): | |
|
31 | """Base class used to create widgets that represent a int that is bounded | |||
|
32 | by a minium and maximum.""" | |||
30 | step = CInt(1, help="Minimum step that the value can take (ignored by some views)", sync=True) |
|
33 | step = CInt(1, help="Minimum step that the value can take (ignored by some views)", sync=True) | |
31 | max = CInt(100, help="Max value", sync=True) |
|
34 | max = CInt(100, help="Max value", sync=True) | |
32 | min = CInt(0, help="Min value", sync=True) |
|
35 | min = CInt(0, help="Min value", sync=True) | |
@@ -43,14 +46,17 b' class _BoundedInt(_Int):' | |||||
43 |
|
46 | |||
44 |
|
47 | |||
45 | class IntText(_Int): |
|
48 | class IntText(_Int): | |
|
49 | """Textbox widget that represents a int.""" | |||
46 | _view_name = Unicode('IntTextView', sync=True) |
|
50 | _view_name = Unicode('IntTextView', sync=True) | |
47 |
|
51 | |||
48 |
|
52 | |||
49 | class BoundedIntText(_BoundedInt): |
|
53 | class BoundedIntText(_BoundedInt): | |
|
54 | """Textbox widget that represents a int bounded by a minimum and maximum value.""" | |||
50 | _view_name = Unicode('IntTextView', sync=True) |
|
55 | _view_name = Unicode('IntTextView', sync=True) | |
51 |
|
56 | |||
52 |
|
57 | |||
53 | class IntSlider(_BoundedInt): |
|
58 | class IntSlider(_BoundedInt): | |
|
59 | """Slider widget that represents a int bounded by a minimum and maximum value.""" | |||
54 | _view_name = Unicode('IntSliderView', sync=True) |
|
60 | _view_name = Unicode('IntSliderView', sync=True) | |
55 | orientation = Enum([u'horizontal', u'vertical'], u'horizontal', |
|
61 | orientation = Enum([u'horizontal', u'vertical'], u'horizontal', | |
56 | help="Vertical or horizontal.", sync=True) |
|
62 | help="Vertical or horizontal.", sync=True) | |
@@ -58,10 +64,11 b' class IntSlider(_BoundedInt):' | |||||
58 |
|
64 | |||
59 |
|
65 | |||
60 | class IntProgress(_BoundedInt): |
|
66 | class IntProgress(_BoundedInt): | |
|
67 | """Progress bar that represents a int bounded by a minimum and maximum value.""" | |||
61 | _view_name = Unicode('ProgressView', sync=True) |
|
68 | _view_name = Unicode('ProgressView', sync=True) | |
62 |
|
69 | |||
63 | _IntWidget = DeprecatedClass(_Int, '_IntWidget') |
|
70 | ||
64 | _BoundedIntWidget = DeprecatedClass(_BoundedInt, '_BoundedIntWidget') |
|
71 | # Remove in IPython 4.0 | |
65 | IntTextWidget = DeprecatedClass(IntText, 'IntTextWidget') |
|
72 | IntTextWidget = DeprecatedClass(IntText, 'IntTextWidget') | |
66 | BoundedIntTextWidget = DeprecatedClass(BoundedIntText, 'BoundedIntTextWidget') |
|
73 | BoundedIntTextWidget = DeprecatedClass(BoundedIntText, 'BoundedIntTextWidget') | |
67 | IntSliderWidget = DeprecatedClass(IntSlider, 'IntSliderWidget') |
|
74 | IntSliderWidget = DeprecatedClass(IntSlider, 'IntSliderWidget') |
@@ -111,21 +111,28 b' class _Selection(DOMWidget):' | |||||
111 |
|
111 | |||
112 |
|
112 | |||
113 | class ToggleButtons(_Selection): |
|
113 | class ToggleButtons(_Selection): | |
|
114 | """Group of toggle buttons that represent an enumeration. Only one toggle | |||
|
115 | button can be toggled at any point in time.""" | |||
114 | _view_name = Unicode('ToggleButtonsView', sync=True) |
|
116 | _view_name = Unicode('ToggleButtonsView', sync=True) | |
115 |
|
117 | |||
116 |
|
118 | |||
117 | class Dropdown(_Selection): |
|
119 | class Dropdown(_Selection): | |
|
120 | """Allows you to select a single item from a dropdown.""" | |||
118 | _view_name = Unicode('DropdownView', sync=True) |
|
121 | _view_name = Unicode('DropdownView', sync=True) | |
119 |
|
122 | |||
120 |
|
123 | |||
121 | class RadioButtons(_Selection): |
|
124 | class RadioButtons(_Selection): | |
|
125 | """Group of radio buttons that represent an enumeration. Only one radio | |||
|
126 | button can be toggled at any point in time.""" | |||
122 | _view_name = Unicode('RadioButtonsView', sync=True) |
|
127 | _view_name = Unicode('RadioButtonsView', sync=True) | |
123 |
|
128 | |||
124 |
|
129 | |||
125 | class Select(_Selection): |
|
130 | class Select(_Selection): | |
|
131 | """Listbox that only allows one item to be selected at any given time.""" | |||
126 | _view_name = Unicode('SelectView', sync=True) |
|
132 | _view_name = Unicode('SelectView', sync=True) | |
127 |
|
133 | |||
128 | _SelectionWidget = DeprecatedClass(_Selection, '_SelectionWidget') |
|
134 | ||
|
135 | # Remove in IPython 4.0 | |||
129 | ToggleButtonsWidget = DeprecatedClass(ToggleButtons, 'ToggleButtonsWidget') |
|
136 | ToggleButtonsWidget = DeprecatedClass(ToggleButtons, 'ToggleButtonsWidget') | |
130 | DropdownWidget = DeprecatedClass(Dropdown, 'DropdownWidget') |
|
137 | DropdownWidget = DeprecatedClass(Dropdown, 'DropdownWidget') | |
131 | RadioButtonsWidget = DeprecatedClass(RadioButtons, 'RadioButtonsWidget') |
|
138 | RadioButtonsWidget = DeprecatedClass(RadioButtons, 'RadioButtonsWidget') |
@@ -22,6 +22,7 b' from IPython.utils.warn import DeprecatedClass' | |||||
22 | # Classes |
|
22 | # Classes | |
23 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
24 | class _SelectionContainer(ContainerWidget): |
|
24 | class _SelectionContainer(ContainerWidget): | |
|
25 | """Base class used to display multiple child widgets.""" | |||
25 | _titles = Dict(help="Titles of the pages", sync=True) |
|
26 | _titles = Dict(help="Titles of the pages", sync=True) | |
26 | selected_index = CInt(0, sync=True) |
|
27 | selected_index = CInt(0, sync=True) | |
27 |
|
28 | |||
@@ -52,12 +53,15 b' class _SelectionContainer(ContainerWidget):' | |||||
52 |
|
53 | |||
53 |
|
54 | |||
54 | class Accordion(_SelectionContainer): |
|
55 | class Accordion(_SelectionContainer): | |
|
56 | """Displays children each on a separate accordion page.""" | |||
55 | _view_name = Unicode('AccordionView', sync=True) |
|
57 | _view_name = Unicode('AccordionView', sync=True) | |
56 |
|
58 | |||
57 |
|
59 | |||
58 | class Tab(_SelectionContainer): |
|
60 | class Tab(_SelectionContainer): | |
|
61 | """Displays children each on a separate accordion tab.""" | |||
59 | _view_name = Unicode('TabView', sync=True) |
|
62 | _view_name = Unicode('TabView', sync=True) | |
60 |
|
63 | |||
61 | _SelectionContainerWidget = DeprecatedClass(_SelectionContainer, '_SelectionContainerWidget') |
|
64 | ||
|
65 | # Remove in IPython 4.0 | |||
62 | AccordionWidget = DeprecatedClass(Accordion, 'AccordionWidget') |
|
66 | AccordionWidget = DeprecatedClass(Accordion, 'AccordionWidget') | |
63 | TabWidget = DeprecatedClass(Tab, 'TabWidget') |
|
67 | TabWidget = DeprecatedClass(Tab, 'TabWidget') |
@@ -21,6 +21,7 b' from IPython.utils.warn import DeprecatedClass' | |||||
21 | # Classes |
|
21 | # Classes | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 | class _String(DOMWidget): |
|
23 | class _String(DOMWidget): | |
|
24 | """Base class used to create widgets that represent a string.""" | |||
24 | value = Unicode(help="String value", sync=True) |
|
25 | value = Unicode(help="String value", sync=True) | |
25 | disabled = Bool(False, help="Enable or disable user changes", sync=True) |
|
26 | disabled = Bool(False, help="Enable or disable user changes", sync=True) | |
26 | description = Unicode(help="Description of the value this widget represents", sync=True) |
|
27 | description = Unicode(help="Description of the value this widget represents", sync=True) | |
@@ -28,14 +29,18 b' class _String(DOMWidget):' | |||||
28 |
|
29 | |||
29 |
|
30 | |||
30 | class HTML(_String): |
|
31 | class HTML(_String): | |
|
32 | """Renders the string `value` as HTML.""" | |||
31 | _view_name = Unicode('HTMLView', sync=True) |
|
33 | _view_name = Unicode('HTMLView', sync=True) | |
32 |
|
34 | |||
33 |
|
35 | |||
34 | class Latex(_String): |
|
36 | class Latex(_String): | |
|
37 | """Renders math inside the string `value` as Latex (requires $ $ or $$ $$ | |||
|
38 | and similar latex tags).""" | |||
35 | _view_name = Unicode('LatexView', sync=True) |
|
39 | _view_name = Unicode('LatexView', sync=True) | |
36 |
|
40 | |||
37 |
|
41 | |||
38 | class Textarea(_String): |
|
42 | class Textarea(_String): | |
|
43 | """Multiline text area widget.""" | |||
39 | _view_name = Unicode('TextareaView', sync=True) |
|
44 | _view_name = Unicode('TextareaView', sync=True) | |
40 |
|
45 | |||
41 | def scroll_to_bottom(self): |
|
46 | def scroll_to_bottom(self): | |
@@ -43,6 +48,7 b' class Textarea(_String):' | |||||
43 |
|
48 | |||
44 |
|
49 | |||
45 | class Text(_String): |
|
50 | class Text(_String): | |
|
51 | """Single line textbox widget.""" | |||
46 | _view_name = Unicode('TextView', sync=True) |
|
52 | _view_name = Unicode('TextView', sync=True) | |
47 |
|
53 | |||
48 | def __init__(self, **kwargs): |
|
54 | def __init__(self, **kwargs): | |
@@ -73,7 +79,8 b' class Text(_String):' | |||||
73 | Whether to unregister the callback""" |
|
79 | Whether to unregister the callback""" | |
74 | self._submission_callbacks.register_callback(callback, remove=remove) |
|
80 | self._submission_callbacks.register_callback(callback, remove=remove) | |
75 |
|
81 | |||
76 | _StringWidget = DeprecatedClass(_String, '_StringWidget') |
|
82 | ||
|
83 | # Remove in IPython 4.0 | |||
77 | HTMLWidget = DeprecatedClass(HTML, 'HTMLWidget') |
|
84 | HTMLWidget = DeprecatedClass(HTML, 'HTMLWidget') | |
78 | LatexWidget = DeprecatedClass(Latex, 'LatexWidget') |
|
85 | LatexWidget = DeprecatedClass(Latex, 'LatexWidget') | |
79 | TextareaWidget = DeprecatedClass(Textarea, 'TextareaWidget') |
|
86 | TextareaWidget = DeprecatedClass(Textarea, 'TextareaWidget') |
General Comments 0
You need to be logged in to leave comments.
Login now