Skip to content
Discussion options

You must be logged in to vote

Hi @dridk,

Here are three possible approaches to choose from:

  1. Wrap your ui.list in a refreshable function and refresh it whenever the slider value changes:

    data = ['one', 'two', 'three']
    slider = ui.slider(value=0, min=0, max=len(data) - 1, step=1)
    
    @ui.refreshable
    def list_ui():
        with ui.list().props('dense separator'):
            for index, name in enumerate(data):
                ui.item(name).classes('bg-green' if index == slider.value else '')
    
    list_ui()
    slider.on_value_change(list_ui.refresh)
  2. Register a value change event handler for every individual list item:

    data = ['one', 'two', 'three']
    slider = ui.slider(value=0, min=0, max=len(data) - 1, step=1)
    
    with ui.list().props('dense s…

Replies: 1 comment 2 replies

Comment options

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

@falkoschindler
Comment options

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