get multiple items chosen in a listbox and populate new list with the
values, using Tkinter
I am trying to take the selection from a listbox and populate a new list
with it, and it will be multiple items. I can't figure this out, here's
what i have so far:
def execute(*events):
UsrFCList = []
selctd_indices = lbox.curselection()
lst_select = list(selctd_indices)
for i in lst_select:
lbox.get(i)
UsrFCList.append(i)
lbox.quit()
fc_lb = Tk()
scrollbar = Scrollbar(fc_lb)
scrollbar.pack(side=RIGHT, fill=Y)
lbox = AutoSzLB(fc_lb,selectmode=EXTENDED)
for item in lb_list:
lbox.insert(END, *item)
button = Button(fc_lb, text="Analyze selected feature classes",
command=execute)
lbox.autowidth(250)
lbox.pack()
button.pack()
lbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=lbox.yview)
mainloop()
No comments:
Post a Comment