Skip to content

Commit 3e63daa

Browse files
author
Zerline
committed
Merge branch 'borders3' of github.com:zerline/ipywidgets into borders3
2 parents c9ed15c + bc4c57a commit 3e63daa

File tree

12 files changed

+322
-180
lines changed

12 files changed

+322
-180
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: Lint
33
on: [push, pull_request]
44

55
jobs:
6-
build:
6+
lint:
7+
name: Lint
78
runs-on: ubuntu-latest
89

910
steps:

.github/workflows/testdocs.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/testjs.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/testpython.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
docs:
7+
name: Documentation
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v1
11+
- name: Set up Python
12+
uses: actions/setup-python@v1
13+
with:
14+
python-version: 3.7
15+
- uses: actions/cache@v1
16+
with:
17+
path: ~/.cache/pip
18+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}-${{hashFiles('**/requirements.txt')}}
19+
restore-keys: |
20+
${{ runner.os }}-pip-
21+
- name: Install dependencies
22+
run: |
23+
sudo apt-get install -y pandoc
24+
python -m pip install --upgrade pip
25+
pip install file://$PWD#egg=ipywidgets
26+
pip install -r ./docs/requirements.txt
27+
- name: Build docs
28+
run: |
29+
cd docs
30+
make html
31+
js:
32+
name: JavaScript
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- uses: actions/checkout@v1
37+
- name: Use Node.js 10.x
38+
uses: actions/setup-node@v1
39+
with:
40+
node-version: 10.x
41+
- name: Install dependencies
42+
run: |
43+
sudo apt-get install -y firefox
44+
- name: Get yarn cache
45+
id: yarn-cache
46+
run: echo "::set-output name=dir::$(yarn cache dir)"
47+
- uses: actions/cache@v1
48+
with:
49+
path: ${{ steps.yarn-cache.outputs.dir }}
50+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
51+
restore-keys: |
52+
${{ runner.os }}-yarn-
53+
- name: yarn install, build, test
54+
run: |
55+
yarn install --frozen-lockfile
56+
yarn run build
57+
yarn run build:examples
58+
59+
pushd packages/base
60+
yarn run test:unit:firefox:headless
61+
popd
62+
63+
pushd packages/base-manager
64+
yarn run test:unit:firefox:headless
65+
popd
66+
67+
pushd packages/controls
68+
yarn run test:unit:firefox:headless
69+
popd
70+
71+
pushd packages/html-manager
72+
yarn run test:unit:firefox:headless
73+
popd
74+
75+
pushd examples/web1
76+
yarn run test:firefox:headless
77+
popd
78+
79+
env:
80+
CI: true
81+
python:
82+
name: Python
83+
runs-on: ubuntu-latest
84+
strategy:
85+
max-parallel: 4
86+
matrix:
87+
python-version: [3.5, 3.6, 3.7, 3.8]
88+
89+
steps:
90+
- uses: actions/checkout@v1
91+
- name: Set up Python ${{ matrix.python-version }}
92+
uses: actions/setup-python@v1
93+
with:
94+
python-version: ${{ matrix.python-version }}
95+
- uses: actions/cache@v1
96+
with:
97+
path: ~/.cache/pip
98+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}-${{hashFiles('**/requirements.txt')}}
99+
restore-keys: |
100+
${{ runner.os }}-pip-
101+
- name: Install dependencies
102+
run: |
103+
python -m pip install --upgrade pip
104+
pip install file://$PWD#egg=ipywidgets[test]
105+
- name: Test with pytest
106+
run: |
107+
pip install pytest
108+
pytest --cov=ipywidgets ipywidgets
109+
spec:
110+
name: Message Specification
111+
runs-on: ubuntu-latest
112+
steps:
113+
- uses: actions/checkout@v1
114+
- name: Set up Python
115+
uses: actions/setup-python@v1
116+
with:
117+
python-version: 3.5
118+
- uses: actions/cache@v1
119+
with:
120+
path: ~/.cache/pip
121+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}-${{hashFiles('**/requirements.txt')}}
122+
restore-keys: |
123+
${{ runner.os }}-pip-
124+
- name: Install dependencies
125+
run: |
126+
python -m pip install --upgrade pip
127+
pip install file://$PWD#egg=ipywidgets
128+
- name: Compare spec with latest version
129+
run: |
130+
python ./packages/schema/generate-spec.py -f markdown > spec.md
131+
diff -u ./packages/schema/jupyterwidgetmodels.latest.md ./spec.md

.github/workflows/testspec.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

ipywidgets/widgets/widget_selectioncontainer.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
from .widget_box import Box
1111
from .widget import register
1212
from .widget_core import CoreWidget
13-
from traitlets import Unicode, Dict, CInt, TraitError, validate
13+
from traitlets import Unicode, Dict, CInt, TraitError, validate, observe
1414

1515

1616
class _SelectionContainer(Box, CoreWidget):
1717
"""Base class used to display multiple child widgets."""
1818
_titles = Dict(help="Titles of the pages").tag(sync=True)
1919
selected_index = CInt(
2020
help="""The index of the selected page. This is either an integer selecting a particular sub-widget, or None to have no widgets selected.""",
21-
allow_none=True
21+
allow_none=True,
22+
default_value=None
2223
).tag(sync=True)
2324

2425
@validate('selected_index')
@@ -28,6 +29,11 @@ def _validated_index(self, proposal):
2829
else:
2930
raise TraitError('Invalid selection: index out of bounds')
3031

32+
@observe('children')
33+
def _observe_children(self, change):
34+
if self.selected_index is not None and len(change.new) < self.selected_index:
35+
self.selected_index = None
36+
3137
# Public methods
3238
def set_title(self, index, title):
3339
"""Sets the title of a container page.
@@ -79,6 +85,10 @@ class Tab(_SelectionContainer):
7985
_view_name = Unicode('TabView').tag(sync=True)
8086
_model_name = Unicode('TabModel').tag(sync=True)
8187

88+
def __init__(self, **kwargs):
89+
if 'children' in kwargs and 'selected_index' not in kwargs and len(kwargs['children']) > 0:
90+
kwargs['selected_index'] = 0
91+
super(Tab, self).__init__(**kwargs)
8292

8393
@register
8494
class Stacked(_SelectionContainer):

packages/controls/src/widget_selectioncontainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class SelectionContainerModel extends BoxModel {
3131
return {
3232
...super.defaults(),
3333
_model_name: 'SelectionContainerModel',
34-
selected_index: 0,
34+
selected_index: null,
3535
_titles: {}
3636
};
3737
}

0 commit comments

Comments
 (0)