Hey @ddutt,
Thanks for the reproducible code sample.
Try changing it to this, it fixes the issue on my end.
import streamlit as st
import time
def create_layout():
foo = st.beta_container()
with foo:
col1, mid, col2 = st.beta_columns([2, 1, 2])
text_col1 = col1.empty()
text_col2 = col2.empty()
_ = st.button('Press Me')
return {
"text1": text_col1,
"text2": text_col2
}
def dynamic_data(text1, text2):
text1.text("""
My three big key insights for distance learning are:
Use the first few days to build a container. NO content teaching. Just set up the ground rules together in a way that lets students experience some of the functionality of the classroom. Practice raising hands, keeping yourself on mute, changing how you see each other. “Let’s work together to create a space that feels brave, safe, and connected. This is new and awkward for all of us – including me. We can start with a list of what’s ok in here and what’s not.” Maybe you can even start with a check-in: Give us one word that describes how you’re feeling about school being online? Great practice of speaking and muting and following along.
Anxiety shows up in weird ways when you’re teaching online. And, people don’t understand the norms. Set the norms so no one takes their computer to the bathroom. (It happened. Twice.) We want everyone to be seen and belong, and that means setting norms and expectations that are co-created with the class. THIS LEARNING ALSO APPLIES TO TEAMS WHO ARE WORKING TOGETHER ONLINE FOR THE FIRST TIME!
Do not assume every student has the same attention span, the same level of wi-fi, access to private space, and the same number of supportive people in their homes. I teach grad students who have to use their phones as hot spots and log-in between jobs or in closets. We have to check our expectations and privilege. We want everyone to be seen and belong.
Small chunks. No more than 30 minutes online. You can meet up several times a day, but the best teachers in the world can’t hold attention longer than that. Think about the research that went into TED setting an 18-minute limit for their talks. That’s all we can take sometimes. You can break kids into small groups for a lengthy assignment, but for the big classroom they will start to drift after 20 minutes. After 30, they’re gone. Heck, I’m gone.
""")
time.sleep(2)
text2.markdown("""
And a note to parents.
I get how hard this is. In the podcast, I talk about hiding from my family in a tuba. It’s overwhelming. Some of us are very ready for virtual school to start up and some of us are scared. However weird the experience may be, we need to partner with teachers to try to make this work. LOTS and lots of grace.
There’s a growing movement of “We’re opting out of homeschooling or participating in the online stuff.” That’s your call. But here’s one thing I would say: Watch screen time. Limitless screen time during an emergency that’s going to last for weeks is not reducing anxiety. It’s throwing gasoline on it. Let them read or do nothing.
Whether we’re onboard for online or we’re opting out, we should all do our kids a huge favor right now and let them experience boredom.
But, we must be ready. Boredom will be an FFT for a lot of our children who have TikTok, memes, and games at the ready, 24 hours a day.
Just as we can come out of our skin during hard first times, they will too. It will take hours of complaining about feeling like they’re dying before they settle into that strange place that’s rarely visited by today’s children – their imagination. We don’t need to entertain them, we need to model vulnerability for them and support them in this FFT.
Boredom is sacred. We shouldn’t deny our children this holy experience.
As we all try to put one foot in front of the other, my team and I are committed to getting relevant content to you via the podcast, social posts, and the blog. Sometimes serious, sometimes not serious at all. We need it all right now!
Once we’re on the other side of this pandemic, we’ll release podcast episodes every Wednesday. Right now, we’re dropping bonus episodes – some COVID-19 related and some not. Please join us!
""")
def _main():
st.set_page_config(layout="wide")
placeholders = create_layout()
dynamic_data(**placeholders)
if __name__ == "__main__":
_main()
The above snippet is one self-made rule that I follow. Allocate placeholders for changing content using .empty(), and give the static content in the create_layout
function and return a dict of the placeholders.
Use these placeholders in another function to dynamically change the elements. It makes the layout way more predictable and the logic / layout code more separate.
I modified it a little more to test it out further and it looks like that was indeed the issue.
import streamlit as st
import time
from random import random
def create_layout():
foo = st.beta_container()
with foo:
col1, mid, col2 = st.beta_columns([2, 1, 2])
text_col1 = col1.empty()
text_col2 = col2.empty()
_ = st.button('Press Me')
return {
"text1": text_col1,
"text2": text_col2
}
x = """
My three big key insights for distance learning are:
Use the first few days to build a container. NO content teaching. Just set up the ground rules together in a way that lets students experience some of the functionality of the classroom. Practice raising hands, keeping yourself on mute, changing how you see each other. “Let’s work together to create a space that feels brave, safe, and connected. This is new and awkward for all of us – including me. We can start with a list of what’s ok in here and what’s not.” Maybe you can even start with a check-in: Give us one word that describes how you’re feeling about school being online? Great practice of speaking and muting and following along.
Anxiety shows up in weird ways when you’re teaching online. And, people don’t understand the norms. Set the norms so no one takes their computer to the bathroom. (It happened. Twice.) We want everyone to be seen and belong, and that means setting norms and expectations that are co-created with the class. THIS LEARNING ALSO APPLIES TO TEAMS WHO ARE WORKING TOGETHER ONLINE FOR THE FIRST TIME!
Do not assume every student has the same attention span, the same level of wi-fi, access to private space, and the same number of supportive people in their homes. I teach grad students who have to use their phones as hot spots and log-in between jobs or in closets. We have to check our expectations and privilege. We want everyone to be seen and belong.
Small chunks. No more than 30 minutes online. You can meet up several times a day, but the best teachers in the world can’t hold attention longer than that. Think about the research that went into TED setting an 18-minute limit for their talks. That’s all we can take sometimes. You can break kids into small groups for a lengthy assignment, but for the big classroom they will start to drift after 20 minutes. After 30, they’re gone. Heck, I’m gone.
"""
y = """
And a note to parents.
I get how hard this is. In the podcast, I talk about hiding from my family in a tuba. It’s overwhelming. Some of us are very ready for virtual school to start up and some of us are scared. However weird the experience may be, we need to partner with teachers to try to make this work. LOTS and lots of grace.
There’s a growing movement of “We’re opting out of homeschooling or participating in the online stuff.” That’s your call. But here’s one thing I would say: Watch screen time. Limitless screen time during an emergency that’s going to last for weeks is not reducing anxiety. It’s throwing gasoline on it. Let them read or do nothing.
Whether we’re onboard for online or we’re opting out, we should all do our kids a huge favor right now and let them experience boredom.
But, we must be ready. Boredom will be an FFT for a lot of our children who have TikTok, memes, and games at the ready, 24 hours a day.
Just as we can come out of our skin during hard first times, they will too. It will take hours of complaining about feeling like they’re dying before they settle into that strange place that’s rarely visited by today’s children – their imagination. We don’t need to entertain them, we need to model vulnerability for them and support them in this FFT.
Boredom is sacred. We shouldn’t deny our children this holy experience.
As we all try to put one foot in front of the other, my team and I are committed to getting relevant content to you via the podcast, social posts, and the blog. Sometimes serious, sometimes not serious at all. We need it all right now!
Once we’re on the other side of this pandemic, we’ll release podcast episodes every Wednesday. Right now, we’re dropping bonus episodes – some COVID-19 related and some not. Please join us!
"""
def dynamic_data(text1, text2):
time.sleep(1)
text1.text(x*int(random()*2))
time.sleep(1)
text2.markdown(y*int(random()*2))
def _main():
st.set_page_config(layout="wide")
placeholders = create_layout()
dynamic_data(**placeholders)
if __name__ == "__main__":
_main()
I am not sure exactly why this happens but it definitely has something to do with streamlit cursor count.
Hope it helps !