Skip to content

Add info to docs on how to set default values for components#1788

Merged
freddyaboulton merged 5 commits into
mainfrom
1688-defaults-values-on-components
Jul 19, 2022
Merged

Add info to docs on how to set default values for components#1788
freddyaboulton merged 5 commits into
mainfrom
1688-defaults-values-on-components

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton commented Jul 13, 2022

Description

Fixes: #1688

Went about this by setting value via keyword arg in the examples and adding a section to the blocks guide about default values

Checklist:

  • I have performed a self-review of my own code
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Comment thread demo/blocks_inputs/run.py
txt = gr.Textbox(label="Input", lines=2)
txt_2 = gr.Textbox(label="Input 2")
txt_3 = gr.Textbox("", label="Output")
btn = gr.Button("Submit")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

In the original issue, the discord user said he couldn't find demos using value despite it being used in demos already.

I figured that was because we didn't set it explicitly with a keyword argument so I went through some demos and set value via keyword arg.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good idea

@@ -0,0 +1,18 @@
import gradio as gr
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adding another demo that sets the default value on the image since there wasn't an example doing that already and that was mentioned on the discord.

Comment thread demo/sentence_builder/run.py
@freddyaboulton freddyaboulton marked this pull request as ready for review July 13, 2022 19:53
@abidlabs
Copy link
Copy Markdown
Member

LGTM!

Copy link
Copy Markdown
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.

LGTM!

You might want to change demo/image_mod_default_image/screenshot.png with a 10KB file instead of 1MB with git soft reset to not increase git size.

@freddyaboulton freddyaboulton force-pushed the 1688-defaults-values-on-components branch from ff46797 to e7f5069 Compare July 19, 2022 14:55
@freddyaboulton freddyaboulton merged commit 8aba1c9 into main Jul 19, 2022
@freddyaboulton freddyaboulton deleted the 1688-defaults-values-on-components branch July 19, 2022 15:16
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.

Add guide (or modify existing guides or demos) to show how to set default values on components

3 participants