James McCool
commited on
Commit
·
9c82393
1
Parent(s):
7daa093
Adjust pagination logic to start from page 1 in app.py
Browse files- Updated the initialization of 'current_page' in session state to start from 1 instead of 0, ensuring accurate page navigation.
- Modified start and end index calculations for pagination to align with the new page numbering, enhancing user experience and clarity in data display.
app.py
CHANGED
@@ -185,7 +185,7 @@ with tab2:
|
|
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 =
|
189 |
|
190 |
# Calculate total pages
|
191 |
rows_per_page = 500
|
@@ -196,10 +196,10 @@ with tab2:
|
|
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'] >
|
200 |
st.session_state.current_page -= 1
|
201 |
else:
|
202 |
-
st.session_state.current_page =
|
203 |
if 'player_frame' in st.session_state:
|
204 |
del st.session_state['player_frame']
|
205 |
del st.session_state['stack_frame']
|
@@ -212,8 +212,8 @@ with tab2:
|
|
212 |
del st.session_state['stack_frame']
|
213 |
|
214 |
# Calculate start and end indices for current page
|
215 |
-
start_idx = st.session_state.current_page * rows_per_page
|
216 |
-
end_idx = min((st.session_state.current_page
|
217 |
st.dataframe(
|
218 |
working_df.iloc[start_idx:end_idx].style
|
219 |
.background_gradient(axis=0)
|
|
|
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 = 1
|
189 |
|
190 |
# Calculate total pages
|
191 |
rows_per_page = 500
|
|
|
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'] > 1:
|
200 |
st.session_state.current_page -= 1
|
201 |
else:
|
202 |
+
st.session_state.current_page = 1
|
203 |
if 'player_frame' in st.session_state:
|
204 |
del st.session_state['player_frame']
|
205 |
del st.session_state['stack_frame']
|
|
|
212 |
del st.session_state['stack_frame']
|
213 |
|
214 |
# Calculate start and end indices for current page
|
215 |
+
start_idx = (st.session_state.current_page - 1) * rows_per_page
|
216 |
+
end_idx = min((st.session_state.current_page) * rows_per_page, total_rows)
|
217 |
st.dataframe(
|
218 |
working_df.iloc[start_idx:end_idx].style
|
219 |
.background_gradient(axis=0)
|