I would like to change the background color of my sidebar and also ensure that my upload button and sidebar buttons display at once and not after the file has been uploaded
Steps to reproduce
Code snippet:
def main():
st.markdown(
"""
<style>
.sidebar .sidebar-content {
background-color: blue; /* Set your desired background color */
}
</style>
""",
unsafe_allow_html=True
)
# creating an empty list for the sidebar
x_col=None
y_col=None
z_col=None
# Upload data from user's local machine
uploaded_file = st.sidebar.file_uploader("", type=["csv", "xlsx"], accept_multiple_files=True, label_visibility="visible")
if uploaded_file is not None:
for files in uploaded_file:
# Process the uploaded file here
try:
d = pd.read_csv(files)
# Continue processing the DataFrame
except UnicodeDecodeError:
d = pd.read_csv(files, encoding='ISO-8859-1') # or encoding='cp1252'
st.write("File uploaded successfully!")
columns = data.columns.tolist()
y_options = data.columns.tolist()
z_options = data.columns.tolist()
st.sidebar.header("Plot Settings")
x_col = st.sidebar.selectbox("Select X Column",[''] + columns)
y_col = st.sidebar.selectbox("Select Y Column",[''] + columns)
z_col=st.sidebar.selectbox("Select z Column",[''] + columns)
plot_title = st.text_input("Enter Plot Title")
if x_col and y_col and z_col:
st.sidebar.success('all required columns selected')
else:
st.sidebar.warning('please select all the required columns before proceeding')
#default filtering option
df=d.loc[data['j']>=0.1]
The code above is displaying the sidebar select buttons after file has been uploaded. If I try to put the select button above the upload files, it is complaining about assignment before refernce