CTkListbox
CTkListbox copied to clipboard
Updating items in the list
I am relatively new to Python, so reading the source code for this is hard for me. Can you please add an example of how to use update_listvar and listvariable to the documentation? I love the way that this frame looks, but I am trying to update the text content of a list item in place and running into errors when I try to delete and re-insert the item.
Basically, I am writing mass spectrometry data reduction software and I want to give the user a list of samples in the sequence, preceded by a ☐ when the data has not been reduced, and a ☑ when the data has been reduced. Also, if the user clicks on a sample in the list, the other frames should be updated to show that sample's data.
This is the function giving me trouble:
# highlights the current sample in the list
def highlight_current_sample(sample_listbox, filtered_data):
global analysis_index
# replace the sample name in the list with a checked box if it is reduced
if filtered_data[analysis_index].reduced and sample_listbox.get(analysis_index)[0] == '☐':
sample_listbox.delete(analysis_index)
sample_listbox.insert(analysis_index, f'☑ {filtered_data[analysis_index].analysis_label}')
sample_listbox.activate(analysis_index)