Let’s say I have a Streamlit app where I want to show the user a lot of images (1k+). Obviously, I wouldn’t want to display these all at once - I need some sort of pagination.
I tried creating a “Next page” and “Previous page” button, but because the button just returns if the button was clicked on the last run of the app it gets stuck in an infinite loop advancing to the next page.
I also tried using a select box, but this had similar issues.
next_action = st.selectbox( 'How would you like to proceed?', ('Stay', 'Next page', 'Previous page') ) if next_action == 'Stay': pass elif next_action == 'Next page': page -= 1 show_images(page=page) elif next_action == 'Previous page': page += 1 show_images(page=page)
What’s the recommended way to handle this case?