Skip to content
Discussion options

You must be logged in to vote

Hi @SHDocter ,

I suppose you mean to create individual pages, for each item from the list? I think this is the same late binding issue that we will find in some of the other discussions.

If you force the loop variable inside your page function, it should work. So something like this below:

pages = ['a', 'b', 'c', 'd']
for page in pages:
    @ui.page(f'/{page}')
    def page_def(page=page):
        ui.label(f'Welcome to page {page}')

So if I use page=page inside the page function, it forces python to use the correct page value, so if you go to any page, now the label value should work correctly.

Thanks,
Anindya

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@falkoschindler
Comment options

@SHDocter
Comment options

Answer selected by SHDocter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants