Skip to content

Commit

Permalink
Expose repeat for the Play Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Jan 6, 2020
1 parent 2a83a76 commit 77c6113
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ipywidgets/widgets/widget_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class Play(_BoundedInt):
_model_name = Unicode('PlayModel').tag(sync=True)

playing = Bool(help="Whether the control is currently playing.").tag(sync=True)
_repeat = Bool(help="Whether the control will repeat in a continous loop.").tag(sync=True)
repeat = Bool(help="Whether the control will repeat in a continous loop.").tag(sync=True)

interval = CInt(100, help="The maximum value for the play control.").tag(sync=True)
step = CInt(1, help="Increment step").tag(sync=True)
Expand Down
16 changes: 8 additions & 8 deletions packages/controls/src/widget_int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ class PlayModel extends BoundedIntModel {
return _.extend(super.defaults(), {
_model_name: 'PlayModel',
_view_name: 'PlayView',
_repeat: false,
repeat: false,
playing: false,
show_repeat: true,
interval: 100,
Expand All @@ -798,7 +798,7 @@ class PlayModel extends BoundedIntModel {
this.set('value', next_value);
this.schedule_next();
} else {
if (this.get('_repeat')) {
if (this.get('repeat')) {
this.set('value', this.get('min'));
this.schedule_next();
} else {
Expand Down Expand Up @@ -849,7 +849,7 @@ class PlayModel extends BoundedIntModel {
}

repeat() {
this.set('_repeat', !this.get('_repeat'));
this.set('repeat', !this.get('repeat'));
this.save_changes();
}

Expand Down Expand Up @@ -898,10 +898,10 @@ class PlayView extends DOMWidgetView {
this.repeatButton.onclick = this.model.repeat.bind(this.model);

this.listenTo(this.model, 'change:playing', this.onPlayingChanged);
this.listenTo(this.model, 'change:_repeat', this.update_repeat);
this.listenTo(this.model, 'change:show_repeat', this.update_repeat);
this.listenTo(this.model, 'change:repeat', this.updateRepeat);
this.listenTo(this.model, 'change:show_repeat', this.updateRepeat);
this.updatePlaying();
this.update_repeat();
this.updateRepeat();
this.update();
}

Expand Down Expand Up @@ -941,8 +941,8 @@ class PlayView extends DOMWidgetView {
}
}

update_repeat() {
let repeat = this.model.get('_repeat');
updateRepeat() {
let repeat = this.model.get('repeat');
this.repeatButton.style.display = this.model.get('show_repeat') ? this.playButton.style.display : 'none';
if (repeat) {
this.repeatButton.classList.add('mod-active');
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/jupyterwidgetmodels.latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,6 @@ Attribute | Type | Default | Help
`_model_module` | string | `'@jupyter-widgets/controls'` |
`_model_module_version` | string | `'1.5.0'` |
`_model_name` | string | `'PlayModel'` |
`_repeat` | boolean | `false` | Whether the control will repeat in a continous loop.
`_view_module` | string | `'@jupyter-widgets/controls'` |
`_view_module_version` | string | `'1.5.0'` |
`_view_name` | string | `'PlayView'` |
Expand All @@ -756,6 +755,7 @@ Attribute | Type | Default | Help
`max` | number (integer) | `100` | Max value
`min` | number (integer) | `0` | Min value
`playing` | boolean | `false` | Whether the control is currently playing.
`repeat` | boolean | `false` | Whether the control will repeat in a continous loop.
`show_repeat` | boolean | `true` | Show the repeat toggle button in the widget.
`step` | number (integer) | `1` | Increment step
`style` | reference to DescriptionStyle widget | reference to new instance | Styling customizations
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/jupyterwidgetmodels.v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ Attribute | Type | Default | Help
`_model_module_version` | string | `'1.4.0'` |
`_model_name` | string | `'PlayModel'` |
`playing` | boolean | `false` | Whether the control is currently playing.
`_repeat` | boolean | `false` | Whether the control will repeat in a continous loop.
`repeat` | boolean | `false` | Whether the control will repeat in a continous loop.
`_view_module` | string | `'@jupyter-widgets/controls'` |
`_view_module_version` | string | `'1.4.0'` |
`_view_name` | string | `'PlayView'` |
Expand Down

0 comments on commit 77c6113

Please sign in to comment.