James McCool
commited on
Commit
·
7daa093
1
Parent(s):
857c2eb
Refine pagination button functionality and session state management in app.py
Browse files- Updated pagination button logic to ensure accurate page navigation, including adjustments to the current page display.
- Enhanced session state management by ensuring the 'current_page' is correctly set and relevant session data is cleared upon navigation, improving user experience.
app.py
CHANGED
|
@@ -183,7 +183,6 @@ with tab2:
|
|
| 183 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
| 184 |
working_df = working_df.drop('sorted', axis=1)
|
| 185 |
|
| 186 |
-
|
| 187 |
# Initialize pagination in session state if not exists
|
| 188 |
if 'current_page' not in st.session_state:
|
| 189 |
st.session_state.current_page = 0
|
|
@@ -196,19 +195,18 @@ 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}"
|
| 200 |
if st.session_state['current_page'] > 0:
|
| 201 |
st.session_state.current_page -= 1
|
|
|
|
|
|
|
| 202 |
if 'player_frame' in st.session_state:
|
| 203 |
del st.session_state['player_frame']
|
| 204 |
del st.session_state['stack_frame']
|
| 205 |
|
| 206 |
with pagination_cols[3]:
|
| 207 |
-
if st.button(f"Page {st.session_state.current_page +
|
| 208 |
-
|
| 209 |
-
st.session_state.current_page = 1
|
| 210 |
-
else:
|
| 211 |
-
st.session_state.current_page += 1
|
| 212 |
if 'player_frame' in st.session_state:
|
| 213 |
del st.session_state['player_frame']
|
| 214 |
del st.session_state['stack_frame']
|
|
|
|
| 183 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
| 184 |
working_df = working_df.drop('sorted', axis=1)
|
| 185 |
|
|
|
|
| 186 |
# Initialize pagination in session state if not exists
|
| 187 |
if 'current_page' not in st.session_state:
|
| 188 |
st.session_state.current_page = 0
|
|
|
|
| 195 |
# Create pagination controls in a single row
|
| 196 |
pagination_cols = st.columns([4, 1, 1, 1, 4])
|
| 197 |
with pagination_cols[1]:
|
| 198 |
+
if st.button(f"Page {st.session_state.current_page - 1}"):
|
| 199 |
if st.session_state['current_page'] > 0:
|
| 200 |
st.session_state.current_page -= 1
|
| 201 |
+
else:
|
| 202 |
+
st.session_state.current_page = 0
|
| 203 |
if 'player_frame' in st.session_state:
|
| 204 |
del st.session_state['player_frame']
|
| 205 |
del st.session_state['stack_frame']
|
| 206 |
|
| 207 |
with pagination_cols[3]:
|
| 208 |
+
if st.button(f"Page {st.session_state.current_page + 1}"):
|
| 209 |
+
st.session_state.current_page += 1
|
|
|
|
|
|
|
|
|
|
| 210 |
if 'player_frame' in st.session_state:
|
| 211 |
del st.session_state['player_frame']
|
| 212 |
del st.session_state['stack_frame']
|