Spaces:
Runtime error
Runtime error
Marc-Alexandre Côté
commited on
Commit
•
3b2cf81
1
Parent(s):
e110d82
Add autoscrolling and rearrange score location
Browse files
app.py
CHANGED
@@ -9,6 +9,10 @@ description = """
|
|
9 |
st.title("ScienceWorld Demo")
|
10 |
st.markdown(description)
|
11 |
|
|
|
|
|
|
|
|
|
12 |
env = st.session_state.get("env")
|
13 |
if env is None:
|
14 |
env = ScienceWorldEnv("")
|
@@ -59,7 +63,7 @@ with st.sidebar:
|
|
59 |
if infos['score'] == 100:
|
60 |
valid_actions = ["", "reset"]
|
61 |
|
62 |
-
#act = st.selectbox('Action:', options=valid_actions, index=0, on_change=step, key="action")
|
63 |
|
64 |
for act, obs in history:
|
65 |
if act:
|
@@ -68,6 +72,10 @@ for act, obs in history:
|
|
68 |
if obs:
|
69 |
st.info(obs.replace('\n\t', '\n- '))
|
70 |
|
|
|
|
|
|
|
|
|
71 |
if infos['score'] == 100:
|
72 |
with st.sidebar:
|
73 |
st.balloons()
|
@@ -75,16 +83,14 @@ if infos['score'] == 100:
|
|
75 |
st.success("Congratulations! You have completed the task.")
|
76 |
|
77 |
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
# # Auto scroll at the bottom of the page.
|
82 |
-
# components.html(
|
83 |
-
# f"""
|
84 |
-
# <p>{st.session_state.obs}</p>
|
85 |
-
# <script>
|
86 |
-
# window.parent.document.querySelector('section.main').scrollTo(0, window.parent.document.querySelector('section.main').scrollHeight);
|
87 |
-
# </script>
|
88 |
# """,
|
89 |
-
|
90 |
-
|
|
|
9 |
st.title("ScienceWorld Demo")
|
10 |
st.markdown(description)
|
11 |
|
12 |
+
# Apply custom CSS.
|
13 |
+
with open('style.css')as f:
|
14 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
15 |
+
|
16 |
env = st.session_state.get("env")
|
17 |
if env is None:
|
18 |
env = ScienceWorldEnv("")
|
|
|
63 |
if infos['score'] == 100:
|
64 |
valid_actions = ["", "reset"]
|
65 |
|
66 |
+
# act = st.selectbox('Action:', options=valid_actions, index=0, on_change=step, key="action")
|
67 |
|
68 |
for act, obs in history:
|
69 |
if act:
|
|
|
72 |
if obs:
|
73 |
st.info(obs.replace('\n\t', '\n- '))
|
74 |
|
75 |
+
act = st.selectbox('Action:', options=valid_actions, index=0, on_change=step, key="action")
|
76 |
+
|
77 |
+
st.warning(f"Current score: {infos['score']} out of 100")
|
78 |
+
|
79 |
if infos['score'] == 100:
|
80 |
with st.sidebar:
|
81 |
st.balloons()
|
|
|
83 |
st.success("Congratulations! You have completed the task.")
|
84 |
|
85 |
|
86 |
+
# Auto scroll at the bottom of the page.
|
87 |
+
components.html(
|
88 |
+
f"""
|
89 |
+
<p>{st.session_state.obs}</p>
|
90 |
+
<script>
|
91 |
+
window.parent.document.querySelector('section.main').scrollTo(0, window.parent.document.querySelector('section.main').scrollHeight);
|
92 |
+
</script>
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
# """,
|
95 |
+
height=0
|
96 |
+
)
|
style.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
section.main[tabindex="0"] {
|
2 |
+
overflow-y: scroll;
|
3 |
+
/* height: 700px */
|
4 |
+
}
|