This commit is contained in:
Ali Abid 2022-07-25 08:45:13 +01:00
parent 9b94701f7e
commit 21f80d77df
6 changed files with 15 additions and 11 deletions

View File

@ -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(

View File

@ -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)

View File

@ -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()

View File

@ -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

View File

@ -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:

View File

@ -19,12 +19,12 @@
<a class="thin-link flex items-center gap-3" href="/getting_started"
><span></span> <span>Quickstart</span>
</a>
<a class="thin-link flex items-center gap-3" href="/docs"
><span>✍️</span> <span>Docs</span>
</a>
<a class="thin-link flex items-center gap-3" href="/guides"
><span>💡</span> <span>Guides</span></a
>
<a class="thin-link flex items-center gap-3" href="/docs"
><span>✍️</span> <span>Docs</span>
</a>
<div
class="group relative flex cursor-pointer items-center gap-3"
onclick='document.querySelector(".help-menu").classList.toggle("flex"),document.querySelector(".help-menu").classList.toggle("hidden")'