From 21f80d77df8a61c4827423cf37dc717da039e11e Mon Sep 17 00:00:00 2001 From: Ali Abid Date: Mon, 25 Jul 2022 08:45:13 +0100 Subject: [PATCH] changes --- demo/blocks_form/run.py | 4 ++-- demo/hangman/run.py | 2 +- .../{2)common_features.md => 2)key_features.md} | 8 +++++--- .../1)blocks_and_event_listeners.md | 4 +++- guides/3)building_with_blocks/2)controlling_layout.md | 2 +- website/homepage/src/templates/navbar.html | 6 +++--- 6 files changed, 15 insertions(+), 11 deletions(-) rename guides/1)getting_started/{2)common_features.md => 2)key_features.md} (95%) diff --git a/demo/blocks_form/run.py b/demo/blocks_form/run.py index f090ccfe63..8a3a9dde53 100644 --- a/demo/blocks_form/run.py +++ b/demo/blocks_form/run.py @@ -10,7 +10,7 @@ with gr.Blocks() as demo: with gr.Column(visible=False) as output_col: diagnosis_box = gr.Textbox(label="Diagnosis") - patient_summary_box = gr.Textbox(label="Patient Summary", visible=False) + patient_summary_box = gr.Textbox(label="Patient Summary") def submit(name, age, symptoms): if len(name) == 0: @@ -20,7 +20,7 @@ with gr.Blocks() as demo: return { output_col: gr.update(visible=True), diagnosis_box: "covid" if "Cough" in symptoms else "flu", - patient_summary_box: gr.update(value=f"{name}, {age} y/o", visible=True) + patient_summary_box: f"{name}, {age} y/o" } submit_btn.click( diff --git a/demo/hangman/run.py b/demo/hangman/run.py index c3f7194435..ddd638f60b 100644 --- a/demo/hangman/run.py +++ b/demo/hangman/run.py @@ -14,7 +14,7 @@ with gr.Blocks() as demo: label="Hangman", value="_"*len(secret_word) ) - used_letters_box = gr.Textbox() + used_letters_box = gr.Textbox(label="Used Letters") def guess_letter(letter, used_letters): used_letters.append(letter) diff --git a/guides/1)getting_started/2)common_features.md b/guides/1)getting_started/2)key_features.md similarity index 95% rename from guides/1)getting_started/2)common_features.md rename to guides/1)getting_started/2)key_features.md index d29e40dac5..ad8047b3f4 100644 --- a/guides/1)getting_started/2)common_features.md +++ b/guides/1)getting_started/2)key_features.md @@ -1,4 +1,4 @@ -# Common Features +# Key Features Let's go through some of the most popular features of Gradio! @@ -50,7 +50,7 @@ num1,operation,num2,Output 6,subtract,1.5,4.5 ``` -With the sepia interface shown above, we would have the flagged data stored in the flagged directory shown below: +With the sepia interface shown earlier, we would have the flagged data stored in the flagged directory shown below: ```directory +-- sepia.py @@ -98,8 +98,10 @@ With `Blocks`: with gr.Blocks() as demo: #... demo.launch(enable_queue=True) +``` -# or to specify only certain functions for queueing +Or to specify only certain functions for queueing in Blocks: +```python with gr.Blocks() as demo2: num1 = gr.Number() num2 = gr.Number() diff --git a/guides/3)building_with_blocks/1)blocks_and_event_listeners.md b/guides/3)building_with_blocks/1)blocks_and_event_listeners.md index d4589e06b2..43fe2144b5 100644 --- a/guides/3)building_with_blocks/1)blocks_and_event_listeners.md +++ b/guides/3)building_with_blocks/1)blocks_and_event_listeners.md @@ -41,7 +41,7 @@ Note that `num1` can act as input to `num2`, and also vice-versa! As your apps g ## Function Return List vs Dict -So far, you have seen event listener functions return a single value for every output component, in the order listed by the event listener. For example: +So far, you have seen event listener functions with multiple outputs return a single value for each output component, in the order listed by the event listener. For example: ```python with gr.Blocks() as demo: @@ -59,6 +59,8 @@ with gr.Blocks() as demo: ) ``` +Above, each return statement returns two values corresponding to `food_box` and `status_box`, respectively. + Instead of returning a list of values corresponing to each output component in order, you can also return a dictionary, with the key corresponding to the output component and the value as the new value. This also allows you to skip updating some output components. ```python diff --git a/guides/3)building_with_blocks/2)controlling_layout.md b/guides/3)building_with_blocks/2)controlling_layout.md index 01db92334c..c66242116f 100644 --- a/guides/3)building_with_blocks/2)controlling_layout.md +++ b/guides/3)building_with_blocks/2)controlling_layout.md @@ -33,7 +33,7 @@ See how the first column has two Textboxes arranged vertically. The second colum ## Tabs -You can also create Tabs using the `with gradio.Tabs():` clause, and create multiple `with gradio.TabItem('tab_name'):` children. Any component created inside of a `with gradio.TabItem(name_of_tab):` context appears in that tab. +You can also create Tabs using the `with gradio.Tabs():` clause, and create multiple `with gradio.TabItem('tab_name'):` children. Any component created inside of a `with gradio.TabItem('tab_name'):` context appears in that tab. For example: diff --git a/website/homepage/src/templates/navbar.html b/website/homepage/src/templates/navbar.html index f7d682ab41..b7e7b2c45d 100644 --- a/website/homepage/src/templates/navbar.html +++ b/website/homepage/src/templates/navbar.html @@ -19,12 +19,12 @@ Quickstart - ✍️ Docs - 💡 Guides + ✍️ Docs +