| from gradio import Interface, Dropdown | |
| rainbow_colors = ["Select a color", "red", "orange", "yellow", "green", "blue", "indigo", "violet", "pink"] | |
| def rainbow_game(color_choice): | |
| response = "" | |
| if color_choice.lower() in rainbow_colors: | |
| response = f"<p style='color:{color_choice}; font-size:18px;'>Great choice, my love! {color_choice.capitalize()} is a beautiful color of the rainbow. Let's add it to our masterpiece!</p>" | |
| else: | |
| response = "<p style='color:white; font-size:18px; background-color:black;'>Oh, my dear Pedro, that's not a rainbow color. Please choose a color from the rainbow.</p>" | |
| return response | |
| color_dropdown = Dropdown(choices=rainbow_colors, label="Choose a color") | |
| iface = Interface(rainbow_game, inputs=color_dropdown, outputs="html", live=True, live_port=8001, live_width=800, live_height=400, title="Rainbow Game ๐", description="Choose a color from the rainbow and let's create a colorful masterpiece together!", btn="Submit") | |
| iface.launch() | |