Skip to content

Commit c8d0b2b

Browse files
committed
Added detailed instruction for Guided breathing
1 parent dd96133 commit c8d0b2b

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

app.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,8 @@ def show_main_page():
246246

247247
# Interactive Widgets
248248
if st.button('Start Guided Breathing'):
249-
st.balloons()
250249
st.write("**Guided Breathing Exercise:** Inhale deeply through your nose for 4 seconds, hold for 4 seconds, and exhale slowly through your mouth. Repeat this process a few times to feel the calming effect.")
251-
250+
box_breathing()
252251

253252
st.write("---")
254253

@@ -820,7 +819,42 @@ def show_calm_space():
820819
st.write("---")
821820
st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
822821

822+
#Guided Breathing
823+
def box_breathing(count=4, cycles=5):
824+
"""
825+
Streamlit-based Box Breathing exercise with centered timer display.
823826
827+
Args:
828+
count (int): Number of seconds for each step in the box breathing cycle.
829+
cycles (int): Number of box breathing cycles to repeat.
830+
"""
831+
# Define steps for the Box Breathing technique
832+
steps = ["Inhale", "Hold", "Exhale", "Hold"]
833+
834+
# Streamlit interface elements
835+
st.title("🧘 Box Breathing Exercise")
836+
st.write("A simple breathing exercise to help you relax and focus. Follow the instructions below.")
837+
838+
for cycle in range(1, cycles + 1):
839+
st.subheader(f"Cycle {cycle} of {cycles}")
840+
841+
for step in steps:
842+
# Create a placeholder for dynamic text updates
843+
placeholder = st.empty()
844+
845+
# Show the step label and countdown in the placeholder
846+
for second in range(count, 0, -1):
847+
placeholder.markdown(f"### {step} - {second} seconds remaining")
848+
time.sleep(1.5) # Pauses the app for 1 second
849+
850+
# Clear the step display after each step
851+
placeholder.empty()
852+
subheader = st.empty()
853+
# Small break between cycles
854+
st.write("Cycle complete.")
855+
time.sleep(2)
856+
857+
st.success("Box Breathing exercise completed. Take a moment to notice how you feel.")
824858

825859

826860
def show_about_and_feedback():

0 commit comments

Comments
 (0)