Skip to content

Commit

Permalink
Add workaround for ipywidgets<=7.3.2 (#62)
Browse files Browse the repository at this point in the history
* Add workaround for ipywidgets<=7.4.2

* make travis fail first

* fix handle_output bug

* Clean

* Fix tests
  • Loading branch information
martinRenou committed Mar 6, 2019
1 parent 6dd08a0 commit 3abc26f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/src/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ let SheetView = widgets.DOMWidgetView.extend({
previous_view = null;
}
}
if (!previous_view && widget && widget.widget_manager) {
widget_view_promises[idx] = widget.widget_manager.create_view(widget)
if (!previous_view && widget) {
widget_view_promises[idx] = this.create_child_view(widget);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions js/src/test/dummy-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ class DummyManager extends widgets.ManagerBase<HTMLElement> {
return Promise.resolve(new MockComm());
}

setViewOptions(options) {
// mimics widgetsnbextension's manager that goes with ipywidgets<=7.3.2
var options = options || {};
if (!options.output && options.parent) {
// use the parent output if we don't have one
options.output = options.parent.options.output;
}
options.iopub_callbacks = {
output: options.output.handle_output.bind(options.output),
clear_output: options.output.handle_clear_output.bind(options.output)
}
return options;
}

el: HTMLElement;
library: any;
}
Expand Down
6 changes: 3 additions & 3 deletions js/src/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export
async function make_view() {
const options = { model: this.sheet };
const view = await this.manager.create_view(this.sheet); //new ipysheet.SheetView(options);
const options = { model: this.sheet, output: {handle_output: () => {}, handle_clear_output: () => {}}};
const view = await this.manager.create_view(this.sheet, options); //new ipysheet.SheetView(options);
await this.manager.display_view(undefined, view);
return view;
}
Expand Down Expand Up @@ -32,4 +32,4 @@ async function make_cell(options, skip_add) {
if(!skip_add)
this.sheet.set('cells', [...cells, cell])
return cell
}
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def run(self):
('etc/jupyter/nbconfig/notebook.d', ['ipysheet.json'])
],
'install_requires': [
'ipywidgets>=7.4.2',
'ipywidgets>=7.0.0',
],
'packages': find_packages(),
'zip_safe': False,
Expand Down

0 comments on commit 3abc26f

Please sign in to comment.