Skip to content

Commit

Permalink
Give the FloatText and IntText a step attribute.
Browse files Browse the repository at this point in the history
For floats, a step of None means any step is allowed.
  • Loading branch information
jasongrout committed Jul 27, 2017
1 parent 387a4b2 commit 7d53455
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ipywidgets/widgets/widget_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ class FloatText(_Float):
----------
value : float
value displayed
step : float
step of the increment (if None, any step is allowed)
description : str
description displayed next to the text box
"""
_view_name = Unicode('FloatTextView').tag(sync=True)
_model_name = Unicode('FloatTextModel').tag(sync=True)
disabled = Bool(False, help="Enable or disable user changes").tag(sync=True)
continuous_update = Bool(False, help="Update the value as the user types.").tag(sync=True)
step = CFloat(None, allow_none=True, help="Minimum step to increment the value").tag(sync=True)


@register
Expand All @@ -92,16 +95,15 @@ class BoundedFloatText(_BoundedFloat):
max : float
maximal value of the range of possible values displayed
step : float
step of the increment
step of the increment (if None, any step is allowed)
description : str
description displayed next to the textbox
"""
_view_name = Unicode('FloatTextView').tag(sync=True)
_model_name = Unicode('BoundedFloatTextModel').tag(sync=True)
disabled = Bool(False, help="Enable or disable user changes").tag(sync=True)
continuous_update = Bool(False, help="Update the value as the user types.").tag(sync=True)
step = CFloat(0.1, help="Minimum step to increment the value").tag(sync=True)

step = CFloat(None, allow_none=True, help="Minimum step to increment the value").tag(sync=True)

@register
class FloatSlider(_BoundedFloat):
Expand Down
1 change: 1 addition & 0 deletions ipywidgets/widgets/widget_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class IntText(_Int):
_model_name = Unicode('IntTextModel').tag(sync=True)
disabled = Bool(False, help="Enable or disable user changes").tag(sync=True)
continuous_update = Bool(False, help="Update the value as the user types.").tag(sync=True)
step = CInt(1, help="Minimum step to increment the value").tag(sync=True)


@register
Expand Down
3 changes: 2 additions & 1 deletion packages/controls/src/widget_int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ class IntTextView extends DescriptionView {
if (this.model.get('max') !== undefined) {
this.textbox.max = this.model.get('max');
}
if (this.model.get('step') !== undefined) {
if (this.model.get('step') !== undefined
&& this.model.get('step') !== null) {
this.textbox.step = this.model.get('step');
} else {
this.textbox.step = this._default_step;
Expand Down

0 comments on commit 7d53455

Please sign in to comment.