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

Update component config #1089

Merged
merged 24 commits into from
May 11, 2022
Merged

Update component config #1089

merged 24 commits into from
May 11, 2022

Conversation

aliabid94
Copy link
Collaborator

@aliabid94 aliabid94 commented Apr 26, 2022

Allow users to update component config parameter with gr.update() or with component gr.Textbox.update(). Changed backend to provide type hints and validation so users can't pass bad parameters.

Valid formats:

  • gr.update(lines=5)
  • gr.Textbox.update(lines=5)
  • gr.Textbox.update(lines=5, value='hello')

See blocks_update/run.py for example
Recording 2022-05-09 at 14 31 45

Also:

  • Added support for visibility changes.
  • Renamed get_template_context to get_config.

@abidlabs
Copy link
Member

Can we have the behavior that setting the value of a component to None hides the component? This is already the case with some components (like Label I think) and it would be good to have uniform behavior across the components and provide a simple way of addressing #784

@abidlabs
Copy link
Member

abidlabs commented May 6, 2022

Can we have the behavior that setting the value of a component to None hides the component? This is already the case with some components (like Label I think) and it would be good to have uniform behavior across the components and provide a simple way of addressing #784

I talked about this some more with @aliabid94 and we felt it would be better to actually just have a property for every component called visible that you could change using this approach

Note that some components (e.g. Label already have the behavior that if you pass None to them, they disappear. We should probably change that)

@aliabid94 aliabid94 marked this pull request as ready for review May 9, 2022 21:33
@aliabid94 aliabid94 requested review from pngwn, omerXfaruq and abidlabs and removed request for pngwn and omerXfaruq May 9, 2022 21:33
@abidlabs
Copy link
Member

abidlabs commented May 9, 2022

Tests need to be updated + see my comments above.

Other than that, works amazing!

Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Looks great 👍

Copy link
Contributor

@omerXfaruq omerXfaruq left a comment

Choose a reason for hiding this comment

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

Good work!

demo/blocks_update/run.py Show resolved Hide resolved
gradio/blocks.py Show resolved Hide resolved
gradio/components.py Outdated Show resolved Hide resolved
@omerXfaruq
Copy link
Contributor

Created the different approach suggestion in #1211 you could drop your thoughts there. @aliabid94

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.

4 participants