Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix .update() method in gr.Dropdown() to handle choices #5529

Merged
merged 6 commits into from Sep 13, 2023

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Sep 13, 2023

Fixes: #5519

Test with original repro in issue:

import gradio as gr

def update_dropdown():
  new_choices = gr.Dropdown.update(choices = ["Hyundai","Suzuki","Mclaren"],label = "Test Dropdown")
  return new_choices

def update_text(text):
  return "You have chosen: " + text

with gr.Blocks() as demo:
  with gr.Row():
    with gr.Column():
      test = gr.Dropdown(choices = ["Honda","BMW","Mercedes"], value = "Honda",label = "Test Dropdown")
      output = gr.Textbox(lines = 5, label="Details")
    with gr.Column():
      test_button = gr.Button(value = "Test",variant = "primary" )
    test.change(update_text,[test],output)
    test_button.click(update_dropdown,[] ,[test])
    
demo.launch()

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Sep 13, 2023

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/634d2f180e2b6dda8629146aba4033f556bf1571/gradio-3.44.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@634d2f180e2b6dda8629146aba4033f556bf1571#subdirectory=client/python"

@abidlabs abidlabs marked this pull request as draft September 13, 2023 17:28
@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Sep 13, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fix .update() method in gr.Dropdown() to handle choices

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs abidlabs marked this pull request as ready for review September 13, 2023 17:44
@@ -650,11 +650,20 @@ def test_in_interface(self):
"""
Interface, process
"""
checkboxes_input = gr.CheckboxGroup(["a", "b", "c"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol whoops

Copy link
Collaborator

@aliabid94 aliabid94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested, works

@abidlabs
Copy link
Member Author

Thanks!

@abidlabs abidlabs merged commit 81c9ca9 into main Sep 13, 2023
16 checks passed
@abidlabs abidlabs deleted the dropdown-update-fix branch September 13, 2023 18:25
@pngwn pngwn mentioned this pull request Sep 13, 2023
@Trimad
Copy link

Trimad commented Sep 15, 2023

Thank you so much. I've already spent more time troubleshooting a dropdown menu that the entire rest of my project. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gr.Dropdown.update unable to render updated choices
4 participants