Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -47,17 +47,18 @@ def delete_last_record():
|
|
47 |
with gr.Blocks() as demo:
|
48 |
gr.Markdown("## 狗狗行为记录")
|
49 |
|
|
|
50 |
with gr.Row():
|
51 |
-
btn_poop = gr.Button("拉屎",
|
52 |
-
btn_pee = gr.Button("尿尿",
|
53 |
-
btn_eat_all = gr.Button("吃东西全吃了",
|
54 |
-
btn_eat_half = gr.Button("吃了一半",
|
55 |
-
btn_eat_none = gr.Button("没吃",
|
56 |
|
57 |
with gr.Row():
|
58 |
-
btn_delete = gr.Button("删除最后一条记录",
|
59 |
|
60 |
-
output = gr.Textbox(label="行为记录", interactive=False,
|
61 |
|
62 |
btn_poop.click(add_record, inputs=["拉屎"], outputs=output)
|
63 |
btn_pee.click(add_record, inputs=["尿尿"], outputs=output)
|
@@ -69,4 +70,14 @@ with gr.Blocks() as demo:
|
|
69 |
# 初始显示记录
|
70 |
show_records()
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
demo.launch()
|
|
|
47 |
with gr.Blocks() as demo:
|
48 |
gr.Markdown("## 狗狗行为记录")
|
49 |
|
50 |
+
# 添加按钮并指定CSS类
|
51 |
with gr.Row():
|
52 |
+
btn_poop = gr.Button("拉屎", elem_classes="poop-btn")
|
53 |
+
btn_pee = gr.Button("尿尿", elem_classes="pee-btn")
|
54 |
+
btn_eat_all = gr.Button("吃东西全吃了", elem_classes="eat-all-btn")
|
55 |
+
btn_eat_half = gr.Button("吃了一半", elem_classes="eat-half-btn")
|
56 |
+
btn_eat_none = gr.Button("没吃", elem_classes="eat-none-btn")
|
57 |
|
58 |
with gr.Row():
|
59 |
+
btn_delete = gr.Button("删除最后一条记录", elem_classes="delete-btn")
|
60 |
|
61 |
+
output = gr.Textbox(label="行为记录", interactive=False, show_label=False)
|
62 |
|
63 |
btn_poop.click(add_record, inputs=["拉屎"], outputs=output)
|
64 |
btn_pee.click(add_record, inputs=["尿尿"], outputs=output)
|
|
|
70 |
# 初始显示记录
|
71 |
show_records()
|
72 |
|
73 |
+
# 添加CSS样式
|
74 |
+
demo.css("""
|
75 |
+
.poop-btn { background-color: brown; }
|
76 |
+
.pee-btn { background-color: blue; }
|
77 |
+
.eat-all-btn { background-color: green; }
|
78 |
+
.eat-half-btn { background-color: orange; }
|
79 |
+
.eat-none-btn { background-color: red; }
|
80 |
+
.delete-btn { background-color: gray; }
|
81 |
+
""")
|
82 |
+
|
83 |
demo.launch()
|