Skip to content

Commit

Permalink
Merge pull request #1728 from alexdaversa/numberSlider
Browse files Browse the repository at this point in the history
Added additional configuration options for numberSlider per issue #1720
  • Loading branch information
jmcouffin authored Mar 24, 2023
2 parents 6ef3c29 + bc7650b commit 4c23a0a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pyrevitlib/pyrevit/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,9 @@ def _setup(self, **kwargs):
self.sliderPrompt.Text = value_prompt
self.numberPicker.Minimum = kwargs.get('min', 0)
self.numberPicker.Maximum = kwargs.get('max', 100)
self.numberPicker.TickFrequency = kwargs.get('interval', 1)
self.numberPicker.Value = \
value_default if isinstance(value_default, float) \
value_default if isinstance(value_default, (float, int)) \
else self.numberPicker.Minimum

def string_value_changed(self, sender, args): #pylint: disable=unused-argument
Expand Down Expand Up @@ -3270,7 +3271,7 @@ def ask_for_date(default=None, prompt=None, title=None, **kwargs):
)


def ask_for_number_slider(default=None, min=0, max=100, prompt=None, title=None, **kwargs):
def ask_for_number_slider(default=None, min=0, max=100, interval=1, prompt=None, title=None, **kwargs):
"""Ask user to select a number value.
This is a shortcut function that configures :obj:`GetValueWindow` for
Expand All @@ -3280,6 +3281,7 @@ def ask_for_number_slider(default=None, min=0, max=100, prompt=None, title=None,
default (str): default unique string. must not be in reserved_values
min (int): minimum value on slider
max (int): maximum value on slider
interval (int): number interval between values
prompt (str): prompt message
title (str): title message
kwargs (type): other arguments to be passed to :obj:`GetValueWindow`
Expand All @@ -3288,20 +3290,27 @@ def ask_for_number_slider(default=None, min=0, max=100, prompt=None, title=None,
str: selected string value
Example:
>>> forms.ask_for_string(
>>> forms.ask_for_number_slider(
... default=50,
... min = 0
... max = 100
... min = 0,
... max = 100,
... interval = 5,
... prompt='Select a number:',
... title='test title')
... '50'
In this example, the slider will allow values such as '40, 45, 50, 55, 60' etc
"""

return GetValueWindow.show(
None,
value_type='slider',
default=default,
prompt=prompt,
title=title,
max=max,
min=min,
interval=interval,
**kwargs
)

Expand Down

0 comments on commit 4c23a0a

Please sign in to comment.