James McCool
commited on
Commit
·
655c1a7
1
Parent(s):
94b689a
Refactor pagination controls in app.py for improved user experience
Browse files- Updated pagination layout to a single row with three columns for better alignment and spacing.
- Enhanced button functionality by disabling the "Previous" and "Next" buttons when on the first or last page, respectively.
- Improved page display formatting using markdown for clearer visibility of current page status.
app.py
CHANGED
@@ -145,15 +145,15 @@ with tab2:
|
|
145 |
total_rows = len(st.session_state['Contest'])
|
146 |
total_pages = (total_rows + rows_per_page - 1) // rows_per_page
|
147 |
|
148 |
-
# Create pagination controls
|
149 |
-
|
150 |
-
with
|
151 |
-
if st.button("Previous
|
152 |
st.session_state.current_page -= 1
|
153 |
-
with
|
154 |
-
st.
|
155 |
-
with
|
156 |
-
if st.button("Next
|
157 |
st.session_state.current_page += 1
|
158 |
|
159 |
# Calculate start and end indices for current page
|
|
|
145 |
total_rows = len(st.session_state['Contest'])
|
146 |
total_pages = (total_rows + rows_per_page - 1) // rows_per_page
|
147 |
|
148 |
+
# Create pagination controls in a single row
|
149 |
+
pagination_cols = st.columns([1, 1, 1, 6]) # Last column for spacing
|
150 |
+
with pagination_cols[0]:
|
151 |
+
if st.button("← Previous", disabled=st.session_state.current_page == 0):
|
152 |
st.session_state.current_page -= 1
|
153 |
+
with pagination_cols[1]:
|
154 |
+
st.markdown(f"**Page {st.session_state.current_page + 1} of {total_pages}**", unsafe_allow_html=True)
|
155 |
+
with pagination_cols[2]:
|
156 |
+
if st.button("Next →", disabled=st.session_state.current_page == total_pages - 1):
|
157 |
st.session_state.current_page += 1
|
158 |
|
159 |
# Calculate start and end indices for current page
|