Spaces:
Sleeping
Sleeping
# 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), | |
) |