fix slider (#1268)

This commit is contained in:
aliabid94 2022-05-15 23:55:35 -07:00 committed by GitHub
parent 40712a2686
commit 569a16998d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 22 additions and 24 deletions

View File

@ -30,8 +30,8 @@ with demo:
)
with gr.Row():
speed = gr.Slider(25, minimum=1, maximum=30, label="Speed")
angle = gr.Slider(45, minimum=0, maximum=90, label="Angle")
speed = gr.Slider(1, 30, 25, label="Speed")
angle = gr.Slider(0, 90, 45, label="Angle")
output = gr.Image(type="plot")
btn = gr.Button("Run")
btn.click(plot, [speed, angle], output)

View File

@ -12,7 +12,7 @@ with gr.Blocks() as demo:
animal = gr.Dropdown(label="Animal", choices=[])
with gr.Column(visible=False) as details_col:
weight = gr.Slider(0, minimum=0, maximum=20)
weight = gr.Slider(0, 20)
details = gr.Textbox(label="Extra Details")
generate_btn = gr.Button("Generate")
output = gr.Textbox(label="Output")

View File

@ -31,8 +31,8 @@ demo = gr.Interface(
inputs=[
gr.Number(label="Generation Count"),
gr.Image(label="Initial Image (optional)"),
gr.Slider(25, minimum=0, maximum=50, label="TV_scale (for smoothness)"),
gr.Slider(25, minimum=0, maximum=50, label="Range_Scale (out of range RBG)"),
gr.Slider(0, 50, 25, label="TV_scale (for smoothness)"),
gr.Slider(0, 50, 25, label="Range_Scale (out of range RBG)"),
gr.Number(label="Seed"),
gr.Number(label="Respacing"),
],

View File

@ -24,7 +24,7 @@ demo = gr.Interface(
gr.CheckboxGroup(
["retail", "food", "other"], value=["retail", "food", "other"]
),
gr.Slider(minimum=1, maximum=3),
gr.Slider(1, 3),
],
[
"dataframe",

View File

@ -19,7 +19,7 @@ demo = gr.Interface(
generate_tone,
[
gr.Dropdown(notes, type="index"),
gr.Slider(value=4, minimum=4, maximum=6, step=1),
gr.Slider(4, 6, step=1),
gr.Textbox(value=1, type="number", label="Duration in seconds"),
],
"audio",

View File

@ -10,7 +10,7 @@ def greet(name, is_morning, temperature):
demo = gr.Interface(
fn=greet,
inputs=["text", "checkbox", gr.Slider(minimum=0, maximum=100)],
inputs=["text", "checkbox", gr.Slider(0, 100)],
outputs=["text", "number"],
)
if __name__ == "__main__":

View File

@ -90,7 +90,7 @@ demo = gr.Interface(
gr.Textbox(value="Lorem ipsum", label="Textbox"),
gr.Textbox(lines=3, placeholder="Type here..", label="Textbox 2"),
gr.Number(label="Number", value=42),
gr.Slider(minimum=10, maximum=20, value=15, label="Slider: 10 - 20"),
gr.Slider(10, 20, value=15, label="Slider: 10 - 20"),
gr.Slider(maximum=20, step=0.04, label="Slider: step @ 0.04"),
gr.Checkbox(label="Checkbox"),
gr.CheckboxGroup(

View File

@ -51,7 +51,7 @@ def outbreak(plot_type, r, month, countries, social_distancing):
inputs = [
gr.Dropdown(["Matplotlib", "Plotly", "Bokeh"], label="Plot Type"),
gr.Slider(minimum=1, maximum=4, value=3.2, label="R"),
gr.Slider(1, 4, 3.2, label="R"),
gr.Dropdown(["January", "February", "March", "April", "May"], label="Month"),
gr.CheckboxGroup(["USA", "Canada", "Mexico", "UK"], label="Countries",
value=["USA", "Canada"]),

View File

@ -8,7 +8,7 @@ def sentence_builder(quantity, animal, place, activity_list, morning):
demo = gr.Interface(
sentence_builder,
[
gr.Slider(minimum=2, maximum=20),
gr.Slider(2, 20),
gr.Dropdown(["cat", "dog", "bird"]),
gr.Radio(["park", "zoo", "road"]),
gr.CheckboxGroup(["ran", "swam", "ate", "slept"]),

View File

@ -28,7 +28,7 @@ demo = gr.Interface(
[
gr.Radio([2025, 2030, 2035, 2040], label="Project to:"),
gr.CheckboxGroup(["Google", "Microsoft", "Gradio"], label="Company Selection"),
gr.Slider(minimum=1, maximum=100, label="Noise Level"),
gr.Slider(1, 100, label="Noise Level"),
gr.Checkbox(label="Show Legend"),
gr.Dropdown(["cross", "line", "circle"], label="Style"),
],

View File

@ -94,7 +94,7 @@ demo = gr.Interface(
[
gr.Dropdown(["first", "second", "third"], type="index"),
"checkbox",
gr.Slider(minimum=0, maximum=80),
gr.Slider(0, 80),
gr.CheckboxGroup(["Sibling", "Child"], label="Travelling with (select all)"),
gr.Number(),
gr.Radio(["S", "C", "Q"], type="index"),

View File

@ -671,10 +671,10 @@ class Slider(Changeable, IOComponent):
def __init__(
self,
value: Optional[float] = None,
*,
minimum: float = 0,
maximum: float = 100,
value: Optional[float] = None,
*,
step: Optional[float] = None,
label: Optional[str] = None,
show_label: bool = True,
@ -685,9 +685,9 @@ class Slider(Changeable, IOComponent):
):
"""
Parameters:
value (float): default value.
minimum (float): minimum value for slider.
maximum (float): maximum value for slider.
value (float): default value.
step (float): increment between slider values.
label (Optional[str]): component name in interface.
show_label (bool): if True, will display label.

View File

@ -109,7 +109,7 @@ import gradio as gr
gr.Interface(
predict,
inputs=[
gr.inputs.Slider(label='Seed', minimum=0, maximum=1000, default=42),
gr.inputs.Slider(0, 1000, label='Seed', default=42),
],
outputs="image",
).launch()
@ -127,8 +127,8 @@ Generating 4 punks at a time is a good start, but maybe we'd like to control how
gr.Interface(
predict,
inputs=[
gr.inputs.Slider(label='Seed', minimum=0, maximum=1000, default=42),
gr.inputs.Slider(label='Number of Punks', minimum=4, maximum=64, step=1, default=10), # Adding another slider!
gr.inputs.Slider(0, 1000, label='Seed', default=42),
gr.inputs.Slider(4, 64, label='Number of Punks', step=1, default=10), # Adding another slider!
],
outputs="image",
).launch()
@ -215,8 +215,8 @@ def predict(seed, num_punks):
gr.Interface(
predict,
inputs=[
gr.inputs.Slider(label='Seed', minimum=0, maximum=1000, default=42),
gr.inputs.Slider(label='Number of Punks', minimum=4, maximum=64, step=1, default=10),
gr.inputs.Slider(0, 1000, label='Seed', default=42),
gr.inputs.Slider(4, 64, label='Number of Punks', step=1, default=10),
],
outputs="image",
examples=[[123, 15], [42, 29], [456, 8], [1337, 35]],

View File

@ -349,9 +349,7 @@ class TestSlider(unittest.TestCase):
self.assertEqual(restored, 3)
self.assertIsInstance(slider_input.generate_sample(), int)
slider_input = gr.Slider(
value=15, minimum=10, maximum=20, step=1, label="Slide Your Input"
)
slider_input = gr.Slider(10, 20, value=15, step=1, label="Slide Your Input")
self.assertEqual(
slider_input.get_config(),
{