# This Gradio app enhances the interactivity and visual appeal of a simple greeting application. # It includes a custom theme, a more engaging layout, and additional components to make the app more interactive. import gradio as gr # Define a custom theme to make the app visually appealing theme = gr.themes.Soft( primary_hue=gr.themes.Color("blue"), secondary_hue=gr.themes.Color("cyan"), neutral_hue=gr.themes.Color("gray"), text_size=gr.themes.Size("md"), spacing_size=gr.themes.Size("md"), radius_size=gr.themes.Size("md"), font=["IBM Plex Sans", "ui-sans-serif", "system-ui", "sans-serif"], font_mono=["IBM Plex Mono", "ui-monospace", "Consolas", "monospace"], ) # Define the greeting function def greet(name): return "Hello " + name + "!" # Create a Gradio Blocks app with a custom theme with gr.Blocks(theme=theme) as demo: # Add a title and a description to make the app more engaging gr.Markdown("# Welcome to the Interactive Greeting App!") gr.Markdown("Enter your name below to get a personalized greeting.") # Create a textbox for user input name_input = gr.Textbox(label="Your Name", placeholder="Enter your name here") # Create a button to trigger the greeting function greet_button = gr.Button("Greet Me", variant="primary") # Create a textbox to display the greeting greeting_output = gr.Textbox(label="Greeting") # Define the event listener for the button click greet_button.click(fn=greet, inputs=name_input, outputs=greeting_output) # Add a feedback section to make the app more interactive gr.Markdown("## Feedback") feedback_input = gr.Textbox(label="Your Feedback", placeholder="Tell us what you think!") submit_feedback_button = gr.Button("Submit Feedback", variant="secondary") feedback_output = gr.Textbox(label="Thank You!") # Define the event listener for the feedback submission def submit_feedback(feedback): return "Thank you for your feedback: " + feedback submit_feedback_button.click(fn=submit_feedback, inputs=feedback_input, outputs=feedback_output) # Launch the app if __name__ == "__main__": demo.launch(show_error=True)