Interactively Cycling Through Data

Iโ€™m trying to use streamlit to build an app where the user can click through a series of datapoints and each will be plotted. To do this I have a doubly linked list of nodes, each indicating a data point the user can plot, and a next and previous button. I made two small callables to update the state of the current list node but that state doesnโ€™t appear to change when the buttons are clicked. Is there a way to get the desired behavior with the out of the box widgets? I posted the code below in case someone can point me in the right direction, thanks!

def move_next(data_node, node_name):
    data_node = data_node.next
    node_name.text(f"{data_node.val}")


# define the file discovery variables
args = _parse_args(sys.argv[1:])
coco_location = _find_coco(Path(args.root))
data_dirs = [Path(walk[0]) for walk in os.walk(coco_location.parent)][1:]
data_node = _list_to_circular_linked_list(data_dirs)
node_name = st.empty()
next_button = st.button('next', on_click=lambda: move_next(data_node, node_name))

@isaak-willett I tried following your question, but it was difficult with the code snippet and description you gave. perhaps resubmit with a full working (or bugged) example with imports, functions, etc; or simplify the ask.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.