Forum Archive

Is there a way to programmatically highlight a ui.SegmentedControl?

ccc

Is there a way to programmatically highlight a segment of a ui.SegmentedControl?

seg = ui.SegmentedControl()
seg.selected_index = 0  # does not set the highlight

See: https://github.com/cclauss/Pythonista_ui/blob/master/segmented_table.py

JonB

setting selected_index works for me, in the beta. Make sure you actually have some segments defined! setting segments clears the highlight. So just move your line down after you define the segments.

ccc

Thanks @JonB that works perfectly.