在tkinter中,我创建了带有for循环的单选按钮,这样它们都有相同的变量来调用方法
for z in posOne: #chief
r = Radiobutton(new, text=z, variable=chief, value=z, indicatoron=0, width=15)
r.place(x=60, y=chiefY)
chiefY += 25
for z in posTwo: #assistant chief
r = Radiobutton(new, text=z, variable=asChief, value=z, indicatoron=0, width=15)
r.place(x=240, y=asChiefY)
asChiefY += 25
for z in posThree: #captain
r = Radiobutton(new, text=z, variable=cap, value=z, indicatoron=0, width=15)
r.place(x=420, y=capY)
capY += 25
for z in posFour: #first lieutenant
r = Radiobutton(new, text=z, variable=lieut, value=z, indicatoron=0, width=15)
r.place(x=600, y=lieutY)
lieutY += 25
当我调用r.deselect()
时,它只取消选择最后一个单选按钮。如何取消选择已经设置好的for循环的所有选项?在
我找到了一种解决问题的方法,将每个单选按钮存储在for循环中的一个列表中,然后调用for循环取消选择该列表中的所有内容
相关问题 更多 >
编程相关推荐