From 68596b2dca6e7cc29dda39d911197b743e1d8cb7 Mon Sep 17 00:00:00 2001 From: Alex D'Aversa Date: Thu, 9 Feb 2023 10:23:03 -0500 Subject: [PATCH 1/3] Added additional configuration options for numberSlider per issue #1720 --- pyrevitlib/pyrevit/forms/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyrevitlib/pyrevit/forms/__init__.py b/pyrevitlib/pyrevit/forms/__init__.py index 4c126e07d..40160f34a 100644 --- a/pyrevitlib/pyrevit/forms/__init__.py +++ b/pyrevitlib/pyrevit/forms/__init__.py @@ -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 @@ -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 @@ -3302,6 +3303,9 @@ def ask_for_number_slider(default=None, min=0, max=100, prompt=None, title=None, default=default, prompt=prompt, title=title, + max=max, + min=min, + interval=interval, **kwargs ) From b375fee963264be7988d358874f98c1d16b7df40 Mon Sep 17 00:00:00 2001 From: Alex D'Aversa Date: Fri, 17 Mar 2023 15:28:25 -0400 Subject: [PATCH 2/3] resolved typo in function arguments, extended documentation on use of interval variable --- pyrevitlib/pyrevit/forms/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pyrevitlib/pyrevit/forms/__init__.py b/pyrevitlib/pyrevit/forms/__init__.py index 40160f34a..dd9aec748 100644 --- a/pyrevitlib/pyrevit/forms/__init__.py +++ b/pyrevitlib/pyrevit/forms/__init__.py @@ -3271,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, interval=1 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 @@ -3281,6 +3281,7 @@ def ask_for_number_slider(default=None, min=0, max=100, interval=1 prompt=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` @@ -3291,12 +3292,16 @@ def ask_for_number_slider(default=None, min=0, max=100, interval=1 prompt=None, Example: >>> forms.ask_for_string( ... 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', From bc7650be14dff654c63a0437b1ec377774d41917 Mon Sep 17 00:00:00 2001 From: Jean-Marc Couffin Date: Fri, 24 Mar 2023 16:44:15 +0100 Subject: [PATCH 3/3] Update __init__.py typo in doc string --- pyrevitlib/pyrevit/forms/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrevitlib/pyrevit/forms/__init__.py b/pyrevitlib/pyrevit/forms/__init__.py index dd9aec748..8a351e69f 100644 --- a/pyrevitlib/pyrevit/forms/__init__.py +++ b/pyrevitlib/pyrevit/forms/__init__.py @@ -3290,7 +3290,7 @@ def ask_for_number_slider(default=None, min=0, max=100, interval=1, prompt=None, str: selected string value Example: - >>> forms.ask_for_string( + >>> forms.ask_for_number_slider( ... default=50, ... min = 0, ... max = 100,