Created
December 14, 2021 15:39
-
-
Save asehmi/c8f5fb302bd39660d2f67241b92020d8 to your computer and use it in GitHub Desktop.
Showing/hiding Streamlit panel containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import numpy as np | |
c1, c2 = st.columns([1,1]) | |
show_p1 = c1.checkbox('Show panel 1', True) | |
show_p2 = c2.checkbox('Show panel 2', True) | |
panel1 = c1.empty() | |
panel2 = c2.empty() | |
@st.experimental_memo() | |
def data(X, Y): | |
return np.random.randn(X, Y) | |
if show_p1: | |
with panel1.container(): | |
st.bar_chart(data(10,3)) | |
else: | |
c1.write('Empty!') | |
panel1 = st.empty() | |
if show_p2: | |
with panel2.container(): | |
st.bar_chart(data(5,6)) | |
else: | |
c2.write('Empty!') | |
panel2 = st.empty() | |
Author
asehmi
commented
Apr 19, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment