|
import gradio as gr |
|
import time |
|
|
|
def update_fortune(user_input): |
|
|
|
|
|
for _ in range(3): |
|
time.sleep(0.5) |
|
|
|
new_image = "fortune2.png" |
|
reserved_text = f"Processed input: {user_input}" |
|
return new_image, reserved_text |
|
|
|
def enquiry_action(): |
|
|
|
|
|
return "Here are some words after the enquiry." |
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# Wong Tai Sin Fortuen Stick Enquiry") |
|
|
|
with gr.Row(): |
|
|
|
with gr.Column(scale=1): |
|
|
|
with gr.Row(): |
|
user_input = gr.Textbox(label="Input Sentence", placeholder="Enter your sentence here...") |
|
submit_btn = gr.Button("Submit") |
|
|
|
|
|
with gr.Column(): |
|
enquiry_btn = gr.Button("解籤/Stick Enquiry") |
|
enquiry_output = gr.Textbox(label="Enquiry Output", placeholder="Output will appear here...") |
|
|
|
|
|
with gr.Column(scale=2): |
|
fortune_image = gr.Image(value="fortune.png", label="Fortune Image", height=300) |
|
reserved_text = gr.Textbox(label="Reserved Text Field", placeholder="Reserved for future content...", interactive=False) |
|
|
|
|
|
|
|
submit_btn.click(fn=update_fortune, inputs=user_input, outputs=[fortune_image, reserved_text]) |
|
|
|
enquiry_btn.click(fn=enquiry_action, inputs=[], outputs=enquiry_output) |
|
|
|
demo.launch() |
|
|