我正试图从一个列表框中删除一个与我的checkbutton函数连接的项。在
ShrimpTempVar=DoubleVar()
ShrimpTempCheck=Checkbutton(menu,variable = ShrimpTempVar, onvalue=5.99, offvalue=0,command=ShrimpTempuraOrder)
def ShrimpTempuraOrder():
if ShrimpTempVar.get()==5.99:
qty=int(QTY2Var.get())
finalprice=ShrimpTempVar.get()*qty
listbox.insert(END, "Shrimp Tempura")
listboxprice.insert( END, finalprice)
elif ShrimpTempVar.get()==0:
listbox.delete(0,END)
listboxprice.delete(0,END)
我希望取消选择该项时将其删除。 在另一篇帖子中,有人建议这样做:
^{pr2}$但它说Listbox在Items中没有属性
另外,我不知道索引号,因为它会随着我选择不同复选按钮的顺序而改变。在
谢谢你的帮助!在
文件
Python Documentation - Common Sequence Operations
The Tkinter Listbox Widget - get(first, last=None)
使用
Listbox
项的标签字符串获取其索引删除此索引处的
Listbox
项使用Python:3.5-TkVersion:8.6测试
相关问题 更多 >
编程相关推荐