Update app.py
Browse files
app.py
CHANGED
@@ -1,56 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
|
4 |
-
|
5 |
-
# Simulate processing and an "animation"
|
6 |
-
for _ in range(3):
|
7 |
-
time.sleep(0.5)
|
8 |
-
# Update the fortune image and reserved text field
|
9 |
-
new_image = "fortune2.png" # New fortune image after submission.
|
10 |
-
reserved_text = f"Processed input: {user_input}" # Placeholder reserved text.
|
11 |
-
# Make the bottom left enquiry components visible.
|
12 |
-
show_bottom = gr.update(visible=True)
|
13 |
-
return new_image, reserved_text, show_bottom, show_bottom
|
14 |
-
|
15 |
-
def enquiry_action():
|
16 |
-
# This function is triggered by the bottom left enquiry button.
|
17 |
-
return "Here are some words after the enquiry."
|
18 |
-
|
19 |
-
with gr.Blocks() as demo:
|
20 |
-
gr.Markdown("# Wong Tai Sin Fortuen Stick Enquiry")
|
21 |
-
|
22 |
-
with gr.Row():
|
23 |
-
# Left column with two sections (top left and bottom left)
|
24 |
-
with gr.Column(scale=1):
|
25 |
-
# Top left container with subtitle and input field + submit button
|
26 |
-
with gr.Group():
|
27 |
-
gr.Markdown("**有什麼問題/Type your question**")
|
28 |
-
with gr.Row():
|
29 |
-
user_input = gr.Textbox(placeholder="Enter your sentence here...", show_label=False)
|
30 |
-
submit_btn = gr.Button("Submit")
|
31 |
-
|
32 |
-
# Bottom left container (initially hidden) with its subtitle and enquiry button
|
33 |
-
with gr.Group(visible=False) as bottom_left_group:
|
34 |
-
gr.Markdown("**解籤/Stick Enquiry**")
|
35 |
-
enquiry_btn = gr.Button("解籤/Stick Enquiry")
|
36 |
-
enquiry_output = gr.Textbox(label="Enquiry Output", placeholder="Output will appear here...")
|
37 |
-
|
38 |
-
# Right column: merged section for fortune image and reserved text
|
39 |
-
with gr.Column(scale=2):
|
40 |
-
gr.Markdown("**籤文/fortune explanation**")
|
41 |
-
fortune_image = gr.Image(value="fortune.png", label=None, height=300)
|
42 |
-
reserved_text = gr.Textbox(label="Reserved Text Field", placeholder="Reserved for future content...", interactive=False)
|
43 |
-
|
44 |
-
# When the submit button is clicked:
|
45 |
-
# - Update the fortune image and reserved text,
|
46 |
-
# - And reveal the bottom left enquiry section.
|
47 |
-
submit_btn.click(
|
48 |
-
fn=update_fortune,
|
49 |
-
inputs=user_input,
|
50 |
-
outputs=[fortune_image, reserved_text, enquiry_btn, enquiry_output]
|
51 |
-
)
|
52 |
-
|
53 |
-
# The enquiry button's click updates its output.
|
54 |
-
enquiry_btn.click(fn=enquiry_action, inputs=[], outputs=enquiry_output)
|
55 |
-
|
56 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
|
4 |
+
print('hi')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|