Hi everyone,
I’ve implemented a st.container in Streamlit with a fixed height of 600 . The container is working well, but when the content exceeds the visible area, it doesn’t scroll automatically.
I’m looking for a solution to enable automatic scrolling ( vertical, depending on content overflow) within this container. Has anyone faced a similar issue or found a workaround?
Would appreciate any suggestions—whether it’s through custom CSS, JavaScript injection, or Streamlit-native methods.
Thanks in advance!
Below is the code for it
import streamlit as st
import subprocess
import time
import keyboard
import os
import psutil
st.set_page_config(page_title="TERMINAL", layout='wide')
st.markdown("""
<style>
.stApp {
background-color: #dedede;
}
</style>
""", unsafe_allow_html=True)
# Create two columns
col1, col2 ,col3= st.columns([1, 6,1])
# Place the buttons in the respective columns
with col1:
start_button = st.button("START EXECUTION")
with col3:
close_button = st.button("CLOSE")
with col2:
if start_button:
command = ["python", '-u', 'run_tests.py']
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True, shell=True)
container = st.container(border=True)
with st.container(height=600):
while process.poll() is None:
line = process.stdout.readline()
if not line:
continue
st.markdown(line.strip())
if close_button:
keyboard.press_and_release('ctrl+w')
pid = os.getpid()
p = psutil.Process(pid)
p.terminate()