Spaces:
Sleeping
Sleeping
File size: 1,542 Bytes
e70400c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# Utility functions for UI components
import gradio as gr
def update_input_visibility(choice, upload_component, url_component, base64_component):
"""
Updates the visibility of input components based on the selected input method.
Args:
choice (str): The selected input method ("Upload File", "Enter URL", "Enter Base64").
upload_component (gr.components): The Gradio component for file upload.
url_component (gr.components): The Gradio component for URL input.
base64_component (gr.components): The Gradio component for Base64 input.
Returns:
tuple: A tuple containing the updated Gradio components with their visibility set.
"""
if choice == "Upload File":
return (
upload_component.update(visible=True),
url_component.update(visible=False),
base64_component.update(visible=False),
)
elif choice == "Enter URL":
return (
upload_component.update(visible=False),
url_component.update(visible=True),
base64_component.update(visible=False),
)
elif choice == "Enter Base64":
return (
upload_component.update(visible=False),
url_component.update(visible=False),
base64_component.update(visible=True),
)
else: # Default or unexpected
return (
upload_component.update(visible=True),
url_component.update(visible=False),
base64_component.update(visible=False),
) |