Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mnowotka committed Apr 12, 2023
1 parent 494b5b4 commit e2f4b13
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def update_params():
st.experimental_set_query_params(
challenge=st.session_state.day.replace(f'{_("Day")} ', "Day"))
challenge=st.session_state.day)


md_files = sorted(
Expand All @@ -28,18 +28,19 @@ def update_params():
st.image(Image.open("streamlit-logo-secondary-colormark-darktext.png"))
st.markdown(_("# 30 Days of Streamlit"))

days_list = [_("Day") + f" {x}" for x in md_files]
days_list = [f"Day{x}" for x in md_files]

if query_params:
try:
selected_day = query_params["challenge"][0].replace("Day", f"{_('Day')} ")
selected_day = query_params["challenge"][0]
if selected_day in days_list:
st.session_state.day = selected_day
except KeyError:
st.session_state.day = days_list[0]

selected_day = st.selectbox(
_("Start the Challenge 👇"), days_list, key="day", on_change=update_params
_("Start the Challenge 👇"), days_list, key="day", on_change=update_params,
format_func=lambda x: x.replace("Day", f'{_("Day")} ')
)

with st.expander(_("About the #30DaysOfStreamlit")):
Expand Down Expand Up @@ -76,16 +77,15 @@ def update_params():
))

# Display content
for i in days_list:
if selected_day == i:
st.markdown(f"# 🗓️ {i}")
j = i.replace(f'{_("Day")} ', "Day")
with open(f"content/{selected_language}/{j}.md", "r") as f:
for day in days_list:
if selected_day == day:
st.markdown("# 🗓️ " + day.replace("Day", f'{_("Day")} '))
with open(f"content/{selected_language}/{day}.md", "r") as f:
st.markdown(f.read())
if os.path.isfile(f"content/{selected_language}/figures/{j}.csv"):
if os.path.isfile(f"content/{selected_language}/figures/{day}.csv"):
st.markdown("---")
st.markdown(_("### Figures"))
df = pd.read_csv(f"content/{selected_language}/figures/{j}.csv", engine="python")
df = pd.read_csv(f"content/{selected_language}/figures/{day}.csv", engine="python")
for i in range(len(df)):
st.image(f"content/{selected_language}/images/{df.img[i]}")
st.info(f"{df.figure[i]}: {df.caption[i]}")

0 comments on commit e2f4b13

Please sign in to comment.