Spaces:
Sleeping
Sleeping
Add autoscrolling
Browse files
app.py
CHANGED
|
@@ -9,6 +9,10 @@ description = """
|
|
| 9 |
st.title("TextWorldExpress Demo")
|
| 10 |
st.markdown(description)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
env = st.session_state.get("env")
|
| 13 |
if env is None:
|
| 14 |
env = TextWorldExpressEnv()
|
|
@@ -96,7 +100,7 @@ def step():
|
|
| 96 |
|
| 97 |
with st.sidebar:
|
| 98 |
# st.warning(env.getTaskDescription())
|
| 99 |
-
|
| 100 |
|
| 101 |
valid_actions = [""] + sorted(infos["validActions"])
|
| 102 |
if infos['done']:
|
|
@@ -128,15 +132,14 @@ elif infos['taskfailure']:
|
|
| 128 |
st.error("You have failed the task.")
|
| 129 |
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
-
|
| 133 |
-
# # Auto scroll at the bottom of the page.
|
| 134 |
-
# components.html(
|
| 135 |
-
# f"""
|
| 136 |
-
# <p>{st.session_state.obs}</p>
|
| 137 |
-
# <script>
|
| 138 |
-
# window.parent.document.querySelector('section.main').scrollTo(0, window.parent.document.querySelector('section.main').scrollHeight);
|
| 139 |
-
# </script>
|
| 140 |
# """,
|
| 141 |
-
|
| 142 |
-
|
|
|
|
| 9 |
st.title("TextWorldExpress 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 = TextWorldExpressEnv()
|
|
|
|
| 100 |
|
| 101 |
with st.sidebar:
|
| 102 |
# st.warning(env.getTaskDescription())
|
| 103 |
+
st.success(f"Score: {infos['score']}")
|
| 104 |
|
| 105 |
valid_actions = [""] + sorted(infos["validActions"])
|
| 106 |
if infos['done']:
|
|
|
|
| 132 |
st.error("You have failed the task.")
|
| 133 |
|
| 134 |
|
| 135 |
+
# Auto scroll at the bottom of the page.
|
| 136 |
+
components.html(
|
| 137 |
+
f"""
|
| 138 |
+
<p>{st.session_state.obs}</p>
|
| 139 |
+
<script>
|
| 140 |
+
window.parent.document.querySelector('section.main').scrollTo(0, window.parent.document.querySelector('section.main').scrollHeight);
|
| 141 |
+
</script>
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
# """,
|
| 144 |
+
height=0
|
| 145 |
+
)
|
style.css
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
section.main[tabindex="0"] {
|
| 2 |
+
overflow-y: scroll;
|
| 3 |
+
/* height: 700px */
|
| 4 |
+
}
|