import gradio as gr import pypokedex import json import utils streaks = utils.get_streak() pokemons = utils.get_pokemon() def new_streak(intensity): global pokemons pokemons = utils.get_pokemon() reward = utils.new_streak(intensity) new_streak = utils.get_streak() return f"{new_streak} streak days", '## ' + '✅ ' * new_streak, reward # def update_pokemon_gallery(): # pokemon_exps = [] # pokemons = utils.get_pokemon() # for dex in pokemons.keys(): # info = gr.Markdown(f"**EXP**: {utils.get_poke_energy(dex)}") # pokemon_exps.append(info) # return pokemon_exps with gr.Blocks() as demo: gr.Markdown('

PokeVerse

') reward_md = gr.Markdown() winning_btn = gr.Button("Are you winning today? 💪") intensity = gr.Slider(0, 3, step=1, label="Intensity") streak_md = gr.Markdown(f"{streaks} streak days") streakboard = gr.Markdown('## ' + '✅ ' * streaks) gr.Markdown('

My Poke Friends

') pokemon_exps = [] with gr.Row(): for dex in pokemons.keys(): with gr.Group(): with gr.Column(min_width=200) as poke_col: gr.Image(pokemons[dex]['image'], show_label=False) with gr.Accordion(pokemons[dex]['name'], open=False): gr.Markdown(pokemons[dex]['description']) info = gr.Markdown(f"**EXP**: {utils.get_poke_energy(dex)}") pokemon_exps.append(info) winning_btn.click(new_streak, inputs=[intensity], outputs=[streak_md, streakboard, reward_md]) # streak_md.change(update_pokemon_gallery, outputs=pokemon_exps) demo.launch()