Skip to content

Commit c56520a

Browse files
authored
Merge pull request #2734 from jasongrout/format
Format files with prettier
2 parents b05400a + de6067a commit c56520a

File tree

120 files changed

+14415
-13504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+14415
-13504
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"recommendations": [
3-
"dbaeumer.vscode-eslint"
4-
]
2+
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
53
}

docs/source/changelog.md

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
ipywidgets changelog
2-
====================
1+
# ipywidgets changelog
32

43
A summary of changes in ipywidgets. For more detailed information, see the issues and pull requests for the appropriate milestone on [GitHub](https://github.com/jupyter-widgets/ipywidgets).
54

6-
7.5
7-
---
5+
## 7.5
86

97
To see the full list of pull requests and issues, see the [7.5 milestone](https://github.com/jupyter-widgets/ipywidgets/milestone/268?closed=1) on GitHub.
108

@@ -19,20 +17,17 @@ Changes include:
1917

2018
Custom widget maintainers will need to update their `@jupyter-widgets/base` dependency version to work in JupyterLab 1.0. For example, if you had a dependency on `@jupyter-widgets/base` version `^1.1`, update to `^1.1 || ^2` for your widget to work in classic notebook, JupyterLab 0.35, and JupyterLab 1.0. See [#2472](https://github.com/jupyter-widgets/ipywidgets/pull/2472) for background.
2119

22-
23-
7.4
24-
---
20+
## 7.4
2521

2622
To see the full list of pull requests and issues, see the [7.4 milestone](https://github.com/jupyter-widgets/ipywidgets/milestone/26?closed=1) on GitHub.
2723

2824
Changes include:
2925

3026
- New `Video` and `Audio` widgets have been introduced. [#2162](https://github.com/jupyter-widgets/ipywidgets/pull/2162)
31-
We updated the `@jupyter-widgets/controls` widget specification version to `1.4.0`, leading to the version bump to 7.4.
27+
We updated the `@jupyter-widgets/controls` widget specification version to `1.4.0`, leading to the version bump to 7.4.
3228
- The use of mappings for the `options` attribute of selection widgets is deprecated. [#2130](https://github.com/jupyter-widgets/ipywidgets/pull/2130)
3329

34-
7.3
35-
---
30+
## 7.3
3631

3732
To see the full list of pull requests and issues, see the [7.3 milestone](https://github.com/jupyter-widgets/ipywidgets/milestone/26?closed=1) on GitHub.
3833

@@ -52,8 +47,7 @@ Changes include:
5247

5348
- The license information has been consolidated into the LICENSE file, and the COPYING.md file is removed. If you are repackaging ipywidgets or widgetsnbextension, please make sure to include LICENSE instead of COPYING.md. ([#2133](https://github.com/jupyter-widgets/ipywidgets/pull/2133), [#2048](https://github.com/jupyter-widgets/ipywidgets/pull/2048), [#1701](https://github.com/jupyter-widgets/ipywidgets/issues/1701), [#1706](https://github.com/jupyter-widgets/ipywidgets/pull/1706))
5449

55-
7.2
56-
---
50+
## 7.2
5751

5852
To see the full list of pull requests and issues, see the [7.2 milestone](https://github.com/jupyter-widgets/ipywidgets/milestone/25?closed=1) on GitHub.
5953

@@ -67,6 +61,7 @@ User-visible changes include:
6761
- `link` and `dlink` are now exported from ipywidgets for convenience, so that you can import them directly from ipywidgets instead of needing to import them from traitlets. ([#1923](https://github.com/jupyter-widgets/ipywidgets/pull/1923))
6862
- A new option `manual_name` has been added to `interact_manual()` to change the name of the update button, for example `interact_manual(manual_name='Update')`. ([#1924](https://github.com/jupyter-widgets/ipywidgets/pull/1923))
6963
- The Output widget now has a `.capture()` method, which returns a decorator to capture the output of a function.
64+
7065
```python
7166
from ipywidgets import Output
7267
out = Output()
@@ -75,7 +70,9 @@ User-visible changes include:
7570
def f():
7671
print('This output is captured')
7772
```
73+
7874
The `.capture()` method has a `clear_output` boolean argument to automatically clear the output every time the function is run, as well as a `wait` argument corresponding to the `clear_output` wait argument. ([#1934](https://github.com/jupyter-widgets/ipywidgets/pull/1934))
75+
7976
- The Output widget has much more comprehensive documentation in its own section. ([#2020](https://github.com/jupyter-widgets/ipywidgets/pull/2020))
8077
- Installing `widgetsnbextension` now automatically enables the nbextension in Jupyter Notebook 5.3 or later. ([#1911](https://github.com/jupyter-widgets/ipywidgets/pull/1911))
8178
- The default rendering of a widget if widgets are not installed is now a short description of the widget in text instead of a much longer HTML message. ([#2007](https://github.com/jupyter-widgets/ipywidgets/pull/2007))
@@ -86,20 +83,17 @@ Changes for developers include:
8683
- The html manager now exposes a way to specify which JavaScript file is fetched for a package and the loader used to fetch the library. ([#1995](https://github.com/jupyter-widgets/ipywidgets/pull/1995), [#1998](https://github.com/jupyter-widgets/ipywidgets/pull/1998))
8784
- The `@jupyter-widgets/controls` widget specification version was bumped to `1.2.0`. Changes include the FloatLogSlider widget and more specific documentation about array element types. ([#2017](https://github.com/jupyter-widgets/ipywidgets/pull/2017))
8885

89-
7.1
90-
---
86+
## 7.1
9187

9288
To see the full list of pull requests and issues, see the [7.1 milestone](https://github.com/jupyter-widgets/ipywidgets/milestone/23?closed=1) on GitHub.
9389

9490
We updated the `@jupyter-widgets/controls` widget specification version to `1.1.0`, leading to the version bump to 7.1. The new widget model specification now includes new `description_width` and `font_weight` attributes for the `ToggleButtonsStyle` widget. There are also other bugfixes in this release.
9591

96-
7.0.x patch releases
97-
--------------------
92+
## 7.0.x patch releases
9893

9994
See the GitHub milestones for the [7.0.1](https://github.com/jupyter-widgets/ipywidgets/milestone/16?closed=1), [7.0.2](https://github.com/jupyter-widgets/ipywidgets/milestone/17?closed=1), [7.0.3](https://github.com/jupyter-widgets/ipywidgets/milestone/18?closed=1), [7.0.4](https://github.com/jupyter-widgets/ipywidgets/milestone/20?closed=1), and [7.0.5](https://github.com/jupyter-widgets/ipywidgets/milestone/21?closed=1) releases for bugfixes in these releases.
10095

101-
7.0
102-
---
96+
## 7.0
10397

10498
To see the full list of pull requests and issues, see the [7.0 milestone](https://github.com/jupyter-widgets/ipywidgets/milestone/12?closed=1) on GitHub.
10599

@@ -111,7 +105,7 @@ Major user-visible changes in ipywidgets 7.0 include:
111105
- The `layout` and `style` traits can be set with a dictionary for convenience, which will automatically converted to a Layout or Style object, like `IntSlider(layout={'width': '100%'}, style={'handle_color': 'lightgreen'})`. ([#1253](https://github.com/jupyter-widgets/ipywidgets/pull/1253))
112106
- The Select widget now is a listbox instead of a dropdown, reverting back to the pre-6.0 behavior. ([#1238](https://github.com/jupyter-widgets/ipywidgets/pull/1238))
113107
- The Select and SelectMultiple widgets now have a `rows` attribute for the number of rows to display, consistent with the Textarea widget. The `layout.height` attribute overrides this to control the height of the widget. ([#1250](https://github.com/jupyter-widgets/ipywidgets/pull/1250))
114-
- Selection widgets (`Select`, `Dropdown`, `ToggleButtons`, etc.) have new `.value`, `.label`, and `.index` traits to make it easier to access or change the selected option. ([#1262](https://github.com/jupyter-widgets/ipywidgets/pull/1262), [#1513](https://github.com/jupyter-widgets/ipywidgets/pull/1513))
108+
- Selection widgets (`Select`, `Dropdown`, `ToggleButtons`, etc.) have new `.value`, `.label`, and `.index` traits to make it easier to access or change the selected option. ([#1262](https://github.com/jupyter-widgets/ipywidgets/pull/1262), [#1513](https://github.com/jupyter-widgets/ipywidgets/pull/1513))
115109
- Selection container widgets (`Accordion`, `Tabs`) can have their `.selected_index` set to `None` to deselect all items. ([#1495](https://github.com/jupyter-widgets/ipywidgets/pull/1495))
116110
- The `Play` widget range is now inclusive (max value is max, instead of max-1), to be consistent with Sliders
117111
- The `Play` widget now has an optional repeat toggle button (visible by default). ([#1190](https://github.com/jupyter-widgets/ipywidgets/pull/1190))
@@ -124,7 +118,7 @@ Major user-visible changes in ipywidgets 7.0 include:
124118
- ToggleButtons have a new `.style.button_width` attribute to set the CSS width of the buttons. Set this to `'initial'` to have buttons that individually size to the content width. ([#1257](https://github.com/jupyter-widgets/ipywidgets/pull/1257))
125119
- The `readout_format` attribute of number sliders now validates its argument. ([#1550](https://github.com/jupyter-widgets/ipywidgets/pull/1550))
126120
- The `IntRangeSlider` widget now has a `.readout_format` trait to control the formatting of the readout. ([#1446](https://github.com/jupyter-widgets/ipywidgets/pull/1446))
127-
- The `Text`, `Textarea`, `IntText`, `BoundedIntText`, `FloatText`, and `BoundedFloatText` widgets all gained a `continuous_update` attribute (defaults to `True` for `Text` and `TextArea`, and `False` for the others). ([#1545](https://github.com/jupyter-widgets/ipywidgets/pull/1545))
121+
- The `Text`, `Textarea`, `IntText`, `BoundedIntText`, `FloatText`, and `BoundedFloatText` widgets all gained a `continuous_update` attribute (defaults to `True` for `Text` and `TextArea`, and `False` for the others). ([#1545](https://github.com/jupyter-widgets/ipywidgets/pull/1545))
128122
- The `IntText`, `BoundedIntText`, `FloatText`, and `BoundedFloatText` widgets are now rendered as HTML number inputs, and have a `step` attribute that controls the resolution. ([#1545](https://github.com/jupyter-widgets/ipywidgets/pull/1545))
129123
- The `Text.on_submit` callback is deprecated; instead, set `continuous_update` to `False` and observe the `value` attribute: `mywidget.observe(callback, 'value')`. The `Textarea.scroll_to_bottom` method was removed. ([#1545](https://github.com/jupyter-widgets/ipywidgets/pull/1545))
130124
- The `msg_throttle` attribute on widgets is now gone, and the code has a hardcoded message throttle equivalent to `msg_throttle=1`. ([#1557](https://github.com/jupyter-widgets/ipywidgets/pull/1557))
@@ -151,24 +145,23 @@ If you are developing a custom widget or widget manager, here are some major cha
151145
- Custom widget managers are now responsible completely for loading widget model and view classes. Widget managers should provide an output model and view class appropriate for their environment so that the `Output` widget works. ([#1313](https://github.com/jupyter-widgets/ipywidgets/pull/1313))
152146
- The widget manager `clear_state` method no longer has a `commlessOnly` argument. All models in the widget manager will be closed and cleared when `clear_state` is called. ([#1354](https://github.com/jupyter-widgets/ipywidgets/pull/1354))
153147

154-
6.0
155-
---
148+
## 6.0
156149

157150
Major user-visible changes in ipywidgets 6.0 include:
158151

159-
- Rendering of Jupyter interactive widgets in various web contexts
152+
- Rendering of Jupyter interactive widgets in various web contexts
160153

161-
sphinx documentation: http://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html
162-
nbviewer: http://nbviewer.jupyter.org/github/jupyter-widgets/ipywidgets/blob/master/docs/source/examples/Widget%20List.ipynb
163-
Static web pages: http://jupyter.org/widgets
154+
sphinx documentation: http://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html
155+
nbviewer: http://nbviewer.jupyter.org/github/jupyter-widgets/ipywidgets/blob/master/docs/source/examples/Widget%20List.ipynb
156+
Static web pages: http://jupyter.org/widgets
164157

165-
- Addition of a DatePicker widget in the core widget collection.
158+
- Addition of a DatePicker widget in the core widget collection.
166159

167-
- Changes to the automatic control generation syntax in @interact, inspired by the Sage interact syntax.
160+
- Changes to the automatic control generation syntax in @interact, inspired by the Sage interact syntax.
168161

169-
- Removal of APIs which had been deprecated in 5.0, including top-level styling in attributes of DOMWidgets and some corner cases in the behavior of `@interact`.
162+
- Removal of APIs which had been deprecated in 5.0, including top-level styling in attributes of DOMWidgets and some corner cases in the behavior of `@interact`.
170163

171-
- A new API for custom styling of widgets is provided, through a top-level `style` attribute. For example, the color of a slider handler can be set by `slider.style.handle_color`.
164+
- A new API for custom styling of widgets is provided, through a top-level `style` attribute. For example, the color of a slider handler can be set by `slider.style.handle_color`.
172165

173166
- Removal of the Proxy and PlaceProxy widgets.
174167

@@ -182,15 +175,16 @@ Major user-visible changes in ipywidgets 6.0 include:
182175

183176
- Removal of the `button_style` attribute of the Dropdown widget
184177

185-
- Addition of an OutputWidget for capturing output and rich display objects. @interact has changed to use an OutputWidget for function output instead of overwriting the output area of a cell.
178+
- Addition of an OutputWidget for capturing output and rich display objects. @interact has changed to use an OutputWidget for function output instead of overwriting the output area of a cell.
186179

187-
- The jupyter-js-widgets Javascript implementation now relies on the PhosphorJS framework for the management of rich layout and a better integration of JupyterLab.
180+
- The jupyter-js-widgets Javascript implementation now relies on the PhosphorJS framework for the management of rich layout and a better integration of JupyterLab.
188181

189182
- Numerous bug fixes.
190183

191-
*Note for custom widget authors:*
184+
_Note for custom widget authors:_
185+
186+
ipywidgets 6.0 breaks backward compatibility with respect to the handling of default values of the JavaScript side. Now, the default values for core widget models are specified with a `default()` method returning a dictionary instead of a `default` dictionary attribute. If you want your library to be backwards compatible with ipywidgets 5.x, you could use [\_.result](http://underscorejs.org/#result) like this:
192187

193-
ipywidgets 6.0 breaks backward compatibility with respect to the handling of default values of the JavaScript side. Now, the default values for core widget models are specified with a `default()` method returning a dictionary instead of a `default` dictionary attribute. If you want your library to be backwards compatible with ipywidgets 5.x, you could use [_.result](http://underscorejs.org/#result) like this:
194188
```javascript
195189
...
196190
defaults: function() {
@@ -201,21 +195,17 @@ defaults: function() {
201195
...
202196
```
203197

204-
205198
This should not have an impact when using your custom widgets in the classic notebook, but will be really important when deploying your interactive widgets in web contexts.
206199

207-
5.x
208-
---
200+
## 5.x
209201

210-
4.1.x
211-
-----
202+
## 4.1.x
212203

213204
### 4.1.1
214205

215206
### 4.1.0
216207

217-
4.0.x
218-
-----
208+
## 4.0.x
219209

220210
### 4.0.3
221211

examples/web1/index.js

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,72 @@ var WidgetManager = require('./manager').WidgetManager;
33

44
require('@jupyter-widgets/controls/css/widgets.css');
55

6-
document.addEventListener("DOMContentLoaded", function(event) {
7-
var manager = new WidgetManager(document.body);
6+
document.addEventListener('DOMContentLoaded', function(event) {
7+
var manager = new WidgetManager(document.body);
88

9-
/**
10-
* Helper function for creating and displaying widgets.
11-
* @return {Promise<WidgetView>}
12-
*/
13-
function createWidget(widgetType, value, description) {
14-
15-
// Create the widget model.
16-
return manager.new_model({
17-
model_module: '@jupyter-widgets/controls',
18-
model_name: widgetType + 'Model',
19-
model_id: 'widget-1'
9+
/**
10+
* Helper function for creating and displaying widgets.
11+
* @return {Promise<WidgetView>}
12+
*/
13+
function createWidget(widgetType, value, description) {
14+
// Create the widget model.
15+
return manager
16+
.new_model({
17+
model_module: '@jupyter-widgets/controls',
18+
model_name: widgetType + 'Model',
19+
model_id: 'widget-1'
2020
// Create a view for the model.
21-
}).then(function(model) {
22-
console.log(widgetType + ' model created');
21+
})
22+
.then(function(model) {
23+
console.log(widgetType + ' model created');
2324

24-
model.set({
25-
description: description || '',
26-
value: value,
27-
});
25+
model.set({
26+
description: description || '',
27+
value: value
28+
});
2829

29-
return manager.create_view(model);
30-
}, console.error.bind(console))
31-
.then(function(view) {
32-
console.log(widgetType + ' view created');
33-
manager.display_view(null, view);
34-
return view;
35-
}, console.error.bind(console));
36-
}
30+
return manager.create_view(model);
31+
}, console.error.bind(console))
32+
.then(function(view) {
33+
console.log(widgetType + ' view created');
34+
manager.display_view(null, view);
35+
return view;
36+
}, console.error.bind(console));
37+
}
3738

38-
var defaultHTML = 'test <b>text</b>';
39-
var textArea = createWidget('Textarea', defaultHTML, 'HTML:');
40-
var html = createWidget('HTML', defaultHTML);
39+
var defaultHTML = 'test <b>text</b>';
40+
var textArea = createWidget('Textarea', defaultHTML, 'HTML:');
41+
var html = createWidget('HTML', defaultHTML);
4142

42-
// Create a link model.
43-
manager.new_model({
44-
model_module: '@jupyter-widgets/controls',
45-
model_name: 'LinkModel',
46-
model_id: 'widget-2',
47-
state: {
48-
'source': null,
49-
'target': null
50-
}
51-
// Set the link model state.
52-
}).then(function(link) {
53-
console.log('link created');
43+
// Create a link model.
44+
manager
45+
.new_model({
46+
model_module: '@jupyter-widgets/controls',
47+
model_name: 'LinkModel',
48+
model_id: 'widget-2',
49+
state: {
50+
source: null,
51+
target: null
52+
}
53+
// Set the link model state.
54+
})
55+
.then(function(link) {
56+
console.log('link created');
5457

55-
return Promise.all([textArea, html]).then(
56-
function(models) {
57-
console.log('setting link');
58-
var textArea = models[0];
59-
var html = models[1];
60-
link.set({
61-
'source': [textArea.model, 'value'],
62-
'target': [html.model, 'value']
63-
});
64-
link.save_changes();
65-
console.log('link set');
66-
}
67-
);
68-
}).then(function() {
69-
var event = new Event('widgetsRendered');
70-
document.dispatchEvent(event);
58+
return Promise.all([textArea, html]).then(function(models) {
59+
console.log('setting link');
60+
var textArea = models[0];
61+
var html = models[1];
62+
link.set({
63+
source: [textArea.model, 'value'],
64+
target: [html.model, 'value']
65+
});
66+
link.save_changes();
67+
console.log('link set');
68+
});
69+
})
70+
.then(function() {
71+
var event = new Event('widgetsRendered');
72+
document.dispatchEvent(event);
7173
});
7274
});

0 commit comments

Comments
 (0)