NavyDevilDoc commited on
Commit
f32e14b
Β·
verified Β·
1 Parent(s): a024831

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +12 -1
src/streamlit_app.py CHANGED
@@ -80,13 +80,24 @@ st.markdown("""
80
  def main():
81
  st.markdown('<div class="main-header">πŸš€ Physics Tutorial: Kinematics</div>', unsafe_allow_html=True)
82
 
 
 
 
 
83
  # Sidebar for navigation
84
  st.sidebar.title("πŸ“š Select Tutorial")
85
  tutorial_type = st.sidebar.radio(
86
  "Choose a physics concept:",
87
- ["1D Motion", "2D Projectile Motion", "Compare Motions"]
 
88
  )
89
 
 
 
 
 
 
 
90
  if tutorial_type == "1D Motion":
91
  show_1d_motion()
92
  elif tutorial_type == "2D Projectile Motion":
 
80
  def main():
81
  st.markdown('<div class="main-header">πŸš€ Physics Tutorial: Kinematics</div>', unsafe_allow_html=True)
82
 
83
+ # Use session state to prevent unnecessary reruns
84
+ if 'current_tab' not in st.session_state:
85
+ st.session_state.current_tab = "1D Motion"
86
+
87
  # Sidebar for navigation
88
  st.sidebar.title("πŸ“š Select Tutorial")
89
  tutorial_type = st.sidebar.radio(
90
  "Choose a physics concept:",
91
+ ["1D Motion", "2D Projectile Motion", "Compare Motions"],
92
+ index=["1D Motion", "2D Projectile Motion", "Compare Motions"].index(st.session_state.current_tab)
93
  )
94
 
95
+ # Only trigger rerun if tab actually changed
96
+ if tutorial_type != st.session_state.current_tab:
97
+ st.session_state.current_tab = tutorial_type
98
+ # Clear matplotlib plots when switching tabs
99
+ plt.close('all')
100
+
101
  if tutorial_type == "1D Motion":
102
  show_1d_motion()
103
  elif tutorial_type == "2D Projectile Motion":