Last active
August 6, 2024 04:08
-
-
Save knowsuchagency/f10969d6cf962f40d8032beb666e2fe0 to your computer and use it in GitHub Desktop.
gradio render example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gradio as gr | |
with gr.Blocks() as demo: | |
subscribed = gr.State(False) | |
update_subscription_btn = gr.Button("Update Subscription") | |
@update_subscription_btn.click(inputs=subscribed, outputs=subscribed) | |
def update_subscription(subscribed): | |
return not subscribed | |
@gr.render(inputs=subscribed) | |
def render_subscription(subscribed): | |
if subscribed: | |
gr.Textbox("You are subscribed") | |
gr.Textbox("You will be billed $10.00 every month") | |
else: | |
gr.Textbox("You are not subscribed") | |
demo.launch() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gradio as gr | |
with gr.Blocks() as demo: | |
subscribed = gr.State(False) | |
@gr.render(inputs=subscribed) | |
def render_subscription(subscribed): | |
update_subscription_btn = gr.Button("Update Subscription") | |
@update_subscription_btn.click(inputs=subscribed, outputs=subscribed) | |
def update_subscription(subscribed): | |
return not subscribed | |
if subscribed: | |
gr.Textbox("You are subscribed") | |
gr.Textbox("You will be billed $10.00 every month") | |
else: | |
gr.Textbox("You are not subscribed") | |
demo.launch() | |
""" | |
File ".../.venv/lib/python3.12/site-packages/gradio/blocks.py", line 575, in get_config | |
"inputs": [block._id for block in self.inputs], | |
^^^^^^^^^ | |
AttributeError: 'bool' object has no attribute '_id' | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment