Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- ui/interface.py +27 -25
ui/interface.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import html
|
| 3 |
|
| 4 |
-
import gradio as gr
|
| 5 |
from game.engine import get_myco_narrative
|
| 6 |
|
| 7 |
def cute_mushroom_garden_html() -> str:
|
|
@@ -192,27 +191,30 @@ def cute_mushroom_garden_html() -> str:
|
|
| 192 |
|
| 193 |
|
| 194 |
def render_shroom_tab():
|
| 195 |
-
|
| 196 |
-
with gr.Blocks()
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import html
|
| 3 |
|
|
|
|
| 4 |
from game.engine import get_myco_narrative
|
| 5 |
|
| 6 |
def cute_mushroom_garden_html() -> str:
|
|
|
|
| 191 |
|
| 192 |
|
| 193 |
def render_shroom_tab():
|
| 194 |
+
"""Renders the Magic Mushroom Garden into the CALLER's current Blocks
|
| 195 |
+
context. Must be called from inside an existing `with gr.Blocks():`
|
| 196 |
+
(e.g. from within a gr.Tab() in build_app()) — do NOT wrap this in its
|
| 197 |
+
own `with gr.Blocks():`, or these components and the narrative Timer
|
| 198 |
+
end up in a separate Blocks graph that never gets launched, so the tab
|
| 199 |
+
renders empty and the Timer never fires.
|
| 200 |
+
"""
|
| 201 |
+
with gr.Tabs():
|
| 202 |
+
with gr.Tab("✨ Magic Mushroom Garden"):
|
| 203 |
+
# The pure animation
|
| 204 |
+
gr.HTML(value=cute_mushroom_garden_html())
|
| 205 |
+
|
| 206 |
+
# Subtle attribution
|
| 207 |
+
gr.Markdown(
|
| 208 |
+
"<sub>*Story generated by Myco AI*</sub>",
|
| 209 |
+
elem_id="ai-attribution"
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
# Define the narrative component ONCE
|
| 213 |
+
narrative = gr.Markdown(
|
| 214 |
+
value="Myco is searching for a story hidden in the moss...",
|
| 215 |
+
elem_id="narrative-card"
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
# Timer updates the ONE narrative component
|
| 219 |
+
gr.Timer(20).tick(fn=get_myco_narrative, outputs=narrative)
|
| 220 |
+
|