MESReport / app.py
ChenyuRabbitLove's picture
refactor: add utils
de7f21d
raw
history blame
2.87 kB
import json
import gradio as gr
from theme import Seafoam
from utils.utils import get_content
seafoam = Seafoam()
def get_player_info(player_backend_user_id):
with open("data.json", "r", encoding="utf-8") as file:
player_info = json.load(file)
return player_info[player_backend_user_id]
# start of gradio interface
with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
with gr.Row():
with gr.Column(
scale=1,
):
pet_gallery = gr.Gallery(
[
"media/partner1.png",
"media/partner2.png",
"media/partner3.png",
"media/partner4.png",
]
* 2,
label="夥伴",
preview=False,
elem_id="pet_gallery",
columns=30,
height=200,
)
pet_description = gr.Markdown("# 夥伴", elem_id="pet_avatar_description")
badge_gallery = gr.Gallery(
[
"media/badge.png",
"media/badge2.png",
"media/badge3.png",
"media/badge4.png",
]
* 2,
show_share_button=True,
label="徽章",
preview=False,
elem_id="badge_gallery",
columns=30,
height=200,
)
badge_description = gr.Markdown("# 徽章", elem_id="badge_avatar_description")
with gr.Column(scale=1):
avatar = gr.Gallery(
["media/avatar.png", "media/avatar2.png"],
preview=True,
elem_id="user_avatar",
)
avatar_description = gr.Markdown(
"# 光束守護者", elem_id="user_avatar_description"
)
with gr.Column(scale=1):
description = gr.Markdown("# 冒險階段", elem_id="adventure_description")
progress_bar_html = (
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
+ get_content("htmls/progress_bar.html")
)
progress_bar = gr.HTML(
progress_bar_html,
)
stage_desc_html = (
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
+ get_content("htmls/stage_desc.html")
)
stage_desc = gr.HTML(
stage_desc_html,
)
with gr.Row():
html = (
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
+ get_content("htmls/achievement.html")
)
f = gr.HTML(html, label="Achievement Log", elem_id="achievement_log")
if __name__ == "__main__":
demo.launch()