Skip to content

Commit 53115b3

Browse files
committed
Rename Stacked widget to Stack
All of our other widgets are present tense, like Accordion, Tab, Box, etc, so the grammar feels like it fits better. As a survey: Toolkits that use "Stack": * flutter: https://api.flutter.dev/flutter/widgets/Stack-class.html * GTK: https://docs.gtk.org/gtk4/class.Stack.html * MUI: https://mui.com/material-ui/react-stack/ * Kivy: https://kivy.org/doc/stable/api-kivy.uix.stacklayout.html?highlight=stack Toolkits that use "Stacked": * QT: https://doc.qt.io/qt-6/qstackedwidget.html
1 parent 46035b4 commit 53115b3

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

docs/source/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ See also the
2727
- Tagsinput widget ([#2591](https://github.com/jupyter-widgets/ipywidgets/pull/2591), [#3272](https://github.com/jupyter-widgets/ipywidgets/pull/3272))
2828
- Drop notebook dependency from widgetsnbextension ([#2590](https://github.com/jupyter-widgets/ipywidgets/pull/2590))
2929
- Cast 'value' in range sliders to a tuple ([#2441](https://github.com/jupyter-widgets/ipywidgets/pull/2441))
30-
- Added a layout widget for 'stacked' layout ([#2376](https://github.com/jupyter-widgets/ipywidgets/pull/2376))
30+
- Added a layout widget for 'stack' layout ([#2376](https://github.com/jupyter-widgets/ipywidgets/pull/2376))
3131
- Play widget: expose playing and repeat ([#2283](https://github.com/jupyter-widgets/ipywidgets/pull/2283), [#1897](https://github.com/jupyter-widgets/ipywidgets/issues/1897))
3232
- Fix debouncing and throttling code ([#3060](https://github.com/jupyter-widgets/ipywidgets/pull/3060))
3333
- Fix regression on spinning icons ([#2685](https://github.com/jupyter-widgets/ipywidgets/pull/2685), [#2477](https://github.com/jupyter-widgets/ipywidgets/issues/2477))

docs/source/examples/Widget List.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,9 +1388,9 @@
13881388
"cell_type": "markdown",
13891389
"metadata": {},
13901390
"source": [
1391-
"### Stacked\n",
1391+
"### Stack\n",
13921392
"\n",
1393-
"The `Stacked` widget can have multiple children widgets as for `Tab` and `Accordion`, but only shows one at a time depending on the value of ``selected_index``:"
1393+
"The `Stack` widget can have multiple children widgets as for `Tab` and `Accordion`, but only shows one at a time depending on the value of ``selected_index``:"
13941394
]
13951395
},
13961396
{
@@ -1401,8 +1401,8 @@
14011401
"source": [
14021402
"button = widgets.Button(description='Click here')\n",
14031403
"slider = widgets.IntSlider()\n",
1404-
"stacked = widgets.Stacked([button, slider], selected_index=0)\n",
1405-
"stacked # will show only the button"
1404+
"stack = widgets.Stack([button, slider], selected_index=0)\n",
1405+
"stack # will show only the button"
14061406
]
14071407
},
14081408
{
@@ -1419,15 +1419,15 @@
14191419
"outputs": [],
14201420
"source": [
14211421
"dropdown = widgets.Dropdown(options=['button', 'slider'])\n",
1422-
"widgets.jslink((dropdown, 'index'), (stacked, 'selected_index'))\n",
1423-
"widgets.VBox([dropdown, stacked])"
1422+
"widgets.jslink((dropdown, 'index'), (stack, 'selected_index'))\n",
1423+
"widgets.VBox([dropdown, stack])"
14241424
]
14251425
},
14261426
{
14271427
"cell_type": "markdown",
14281428
"metadata": {},
14291429
"source": [
1430-
"### Accordion, Tab, and Stacked use `selected_index`, not value\n",
1430+
"### Accordion, Tab, and Stack use `selected_index`, not value\n",
14311431
"\n",
14321432
"Unlike the rest of the widgets discussed earlier, the container widgets `Accordion` and `Tab` update their `selected_index` attribute when the user changes which accordion or tab is selected. That means that you can both see what the user is doing *and* programmatically set what the user sees by setting the value of `selected_index`.\n",
14331433
"\n",

packages/controls/src/widget_selectioncontainer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,17 @@ export class TabView extends DOMWidgetView {
422422
luminoWidget: JupyterLuminoTabPanelWidget;
423423
}
424424

425-
export class StackedModel extends SelectionContainerModel {
425+
export class StackModel extends SelectionContainerModel {
426426
defaults(): Backbone.ObjectHash {
427427
return {
428428
...super.defaults(),
429-
_model_name: 'StackedModel',
430-
_view_name: 'StackedView',
429+
_model_name: 'StackModel',
430+
_view_name: 'StackView',
431431
};
432432
}
433433
}
434434

435-
export class StackedView extends BoxView {
435+
export class StackView extends BoxView {
436436
initialize(parameters: WidgetView.IInitializeParameters): void {
437437
super.initialize(parameters);
438438
this.listenTo(this.model, 'change:selected_index', this.update_children);

packages/schema/jupyterwidgetmodels.latest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6554,7 +6554,7 @@
65546554
"type": "string"
65556555
},
65566556
{
6557-
"default": "StackedModel",
6557+
"default": "StackModel",
65586558
"help": "",
65596559
"name": "_model_name",
65606560
"type": "string"
@@ -6572,7 +6572,7 @@
65726572
"type": "string"
65736573
},
65746574
{
6575-
"default": "StackedView",
6575+
"default": "StackView",
65766576
"help": "",
65776577
"name": "_view_name",
65786578
"type": "string"
@@ -6634,12 +6634,12 @@
66346634
],
66356635
"model": {
66366636
"module": "@jupyter-widgets/controls",
6637-
"name": "StackedModel",
6637+
"name": "StackModel",
66386638
"version": "2.0.0"
66396639
},
66406640
"view": {
66416641
"module": "@jupyter-widgets/controls",
6642-
"name": "StackedView",
6642+
"name": "StackView",
66436643
"version": "2.0.0"
66446644
}
66456645
},

packages/schema/jupyterwidgetmodels.latest.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,17 +1168,17 @@ Attribute | Type | Default | Help
11681168
`description_width` | string | `''` | Width of the description to the side of the control.
11691169
`handle_color` | `null` or string | `null` | Color of the slider handle.
11701170

1171-
### StackedModel (@jupyter-widgets/controls, 2.0.0); StackedView (@jupyter-widgets/controls, 2.0.0)
1171+
### StackModel (@jupyter-widgets/controls, 2.0.0); StackView (@jupyter-widgets/controls, 2.0.0)
11721172

11731173
Attribute | Type | Default | Help
11741174
-----------------|------------------|------------------|----
11751175
`_dom_classes` | array of string | `[]` | CSS classes applied to widget DOM element
11761176
`_model_module` | string | `'@jupyter-widgets/controls'` |
11771177
`_model_module_version` | string | `'2.0.0'` |
1178-
`_model_name` | string | `'StackedModel'` |
1178+
`_model_name` | string | `'StackModel'` |
11791179
`_view_module` | string | `'@jupyter-widgets/controls'` |
11801180
`_view_module_version` | string | `'2.0.0'` |
1181-
`_view_name` | string | `'StackedView'` |
1181+
`_view_name` | string | `'StackView'` |
11821182
`box_style` | string (one of `'success'`, `'info'`, `'warning'`, `'danger'`, `''`) | `''` | Use a predefined styling for the box.
11831183
`children` | array of reference to Widget widget | `[]` | List of widget children
11841184
`layout` | reference to Layout widget | reference to new instance |

python/ipywidgets/ipywidgets/widgets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .widget_time import TimePicker
2020
from .widget_output import Output
2121
from .widget_selection import RadioButtons, ToggleButtons, ToggleButtonsStyle, Dropdown, Select, SelectionSlider, SelectMultiple, SelectionRangeSlider
22-
from .widget_selectioncontainer import Tab, Accordion, Stacked
22+
from .widget_selectioncontainer import Tab, Accordion, Stack
2323
from .widget_string import HTML, HTMLMath, Label, Text, Textarea, Password, Combobox
2424
from .widget_controller import Controller
2525
from .interaction import interact, interactive, fixed, interact_manual, interactive_output

python/ipywidgets/ipywidgets/widgets/tests/test_selectioncontainer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from traitlets import TraitError
77

8-
from ipywidgets.widgets import Accordion, Tab, Stacked, HTML
8+
from ipywidgets.widgets import Accordion, Tab, Stack, HTML
99

1010
class TestTab(TestCase):
1111

@@ -113,11 +113,11 @@ def test_titles(self):
113113
assert len(widget.children) == 1
114114
assert widget.titles == ('',)
115115

116-
class TestStacked(TestCase):
116+
class TestStack(TestCase):
117117

118118
def setUp(self):
119119
self.children = [HTML('0'), HTML('1')]
120-
self.widget = Stacked
120+
self.widget = Stack
121121

122122
def test_selected_index_none(self):
123123
widget = self.widget(self.children, selected_index=None)

python/ipywidgets/ipywidgets/widgets/widget_selectioncontainer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _reset_selected_index(self):
114114

115115

116116
@register
117-
class Stacked(_SelectionContainer):
117+
class Stack(_SelectionContainer):
118118
"""Displays only the selected child."""
119-
_view_name = Unicode('StackedView').tag(sync=True)
120-
_model_name = Unicode('StackedModel').tag(sync=True)
119+
_view_name = Unicode('StackView').tag(sync=True)
120+
_model_name = Unicode('StackModel').tag(sync=True)

0 commit comments

Comments
 (0)