James McCool commited on
Commit
857c2eb
·
1 Parent(s): db18707

Update pagination button labels for accurate page navigation in app.py

Browse files

- Adjusted button labels to reflect the correct current page number, enhancing clarity for users navigating through pages.
- Ensured session state management remains intact by maintaining the clearing of relevant data upon page transitions.

Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -196,7 +196,7 @@ with tab2:
196
  # Create pagination controls in a single row
197
  pagination_cols = st.columns([4, 1, 1, 1, 4])
198
  with pagination_cols[1]:
199
- if st.button(f"Page {st.session_state.current_page - 1}", disabled=st.session_state.current_page == 0):
200
  if st.session_state['current_page'] > 0:
201
  st.session_state.current_page -= 1
202
  if 'player_frame' in st.session_state:
@@ -204,7 +204,7 @@ with tab2:
204
  del st.session_state['stack_frame']
205
 
206
  with pagination_cols[3]:
207
- if st.button(f"Page {st.session_state.current_page + 1}", disabled=st.session_state.current_page == total_pages - 1):
208
  if 'current_page' not in st.session_state:
209
  st.session_state.current_page = 1
210
  else:
@@ -212,7 +212,7 @@ with tab2:
212
  if 'player_frame' in st.session_state:
213
  del st.session_state['player_frame']
214
  del st.session_state['stack_frame']
215
-
216
  # Calculate start and end indices for current page
217
  start_idx = st.session_state.current_page * rows_per_page
218
  end_idx = min((st.session_state.current_page + 1) * rows_per_page, total_rows)
 
196
  # Create pagination controls in a single row
197
  pagination_cols = st.columns([4, 1, 1, 1, 4])
198
  with pagination_cols[1]:
199
+ if st.button(f"Page {st.session_state.current_page}", disabled=st.session_state.current_page == 0):
200
  if st.session_state['current_page'] > 0:
201
  st.session_state.current_page -= 1
202
  if 'player_frame' in st.session_state:
 
204
  del st.session_state['stack_frame']
205
 
206
  with pagination_cols[3]:
207
+ if st.button(f"Page {st.session_state.current_page + 2}", disabled=st.session_state.current_page == total_pages - 1):
208
  if 'current_page' not in st.session_state:
209
  st.session_state.current_page = 1
210
  else:
 
212
  if 'player_frame' in st.session_state:
213
  del st.session_state['player_frame']
214
  del st.session_state['stack_frame']
215
+
216
  # Calculate start and end indices for current page
217
  start_idx = st.session_state.current_page * rows_per_page
218
  end_idx = min((st.session_state.current_page + 1) * rows_per_page, total_rows)