In the first tab you load data, in the second you define the chart parameters and plot your chart.
The widgets in both tabs are organized in four columns. So the stuff that is under the tabs in the four columns is - correctly - only visible under “their” tab (disappears as expected, if when you change tab).
To allow for plotting a larger plot, in the second tab, I “break” my four columns and substitute them with a new set of two (larger) columns.
The result is that my chart is visible on both tabs, which is not what I want.
Is there a way to make tabs “own” a “hierarchy” of columns that might change?
4 cols each for tab 1 and tab 2 and dog picture visible only when in Tab 1 and owl picture visible only when in tab 2.
It works fine. I went back to my code made a couple of modifications and works fine there two. Thanks again.
import streamlit as st
def run_first_tab():
with tab1:
colWidthArray=[1,1,1,1]
col1,col2,col3,col4 = st.columns(colWidthArray)
with col1:
st.info("A in col 1 tab I")
with col2:
st.info("B in col 2 tab I")
with col3:
st.info("C in col 3 tab I")
with col4:
st.info("D in col 4 tab I")
st.image("https://static.streamlit.io/examples/dog.jpg")
return None
def run_second_tab():
with tab2:
colWidthArray=[1,1,1,1]
col1,col2,col3,col4 = st.columns(colWidthArray)
with col1:
st.info("E in col 1 tab II")
with col2:
st.info("F in col 2 tab II")
with col3:
st.info("G in col 3 tab II")
with col4:
st.info("H in col 4 tab II")
colWidthArray=[1,1]
colA,colB = st.columns(colWidthArray)
with colB:
st.image("https://static.streamlit.io/examples/owl.jpg", width=400)
return None
tab1, tab2 = st.tabs(["first tab with with 4 cols and dog", "second tab with 4 cols and owl"])
run_first_tab()
run_second_tab()
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.