switched to object syntax for columns; use to_hdf_binary; some cleanup

This commit is contained in:
2022-05-23 12:54:33 +02:00
parent 48c163f9d7
commit 159bfca9b1

View File

@ -1,32 +1,31 @@
import streamlit as st
from utils.df_utils import to_excel_binary
from utils.df_utils import to_excel_binary, to_hdf_binary
state = st.session_state
def download(df):
showing_downloads = st.session_state.get("showing_downloads", False)
showing_downloads = state.get("showing_downloads", False)
col1, col2, col3, col4 = st.columns([1, 1, 1, 1])
with col1:
if st.button("Downloads") and not showing_downloads:
st.session_state.showing_downloads = True
col0, col1, col2, col3 = st.columns(4)
if col0.button("Downloads") and not showing_downloads:
state.showing_downloads = True
with col2:
with open("output.h5", "rb") as f:
st.download_button("📥 hdf5", f, file_name="output.h5")
h5 = to_hdf_binary(df)
col1.download_button("📥 hdf5", h5, file_name="output.h5")
with col3:
xlsx = to_excel_binary(df)
st.download_button("📥 xlsx", xlsx, file_name="output.xlsx")
xlsx = to_excel_binary(df)
col2.download_button("📥 xlsx", xlsx, file_name="output.xlsx")
with col4:
csv = df.to_csv()
st.download_button("📥 csv", csv, file_name="output.csv")
csv = df.to_csv()
col3.download_button("📥 csv", csv, file_name="output.csv")
# st.stop()
# st.stop()
else:
st.session_state.showing_downloads = False
else:
state.showing_downloads = False