【发布时间】:2016-11-10 13:20:07
【问题描述】:
我有这个清单:
lista=Listbox(root,selectmode=MULTIPLE)
lista.grid(column=0,row=1)
lista.config(width=40, height=4)
lista.bind('<<ListboxSelect>>',selecionado)
附加到这个函数:
def selecionado(evt):
global ativo
a=evt.widget
seleção=int(a.curselection()[0])
sel_text=a.get(seleção)
ativo=[a.get(int(i)) for i in a.curselection()]
但是如果我选择了一些东西然后取消选择,我会得到这个错误:
seleção=int(a.curselection()[0])
IndexError: tuple index out of rangeenter code here
如何防止这种情况发生?
【问题讨论】: