-1
我需要一個按鈕來清除選中的複選框。請任何人指導我。提前致謝。如何在python中使用按鈕取消選擇複選框?
import Tkinter
from Tkinter import*
top = Tkinter.Tk()
CheckVar1=IntVar()
CheckVar2=IntVar()
C1=Checkbutton(top, text = "Music", variable = CheckVar1,
onvalue = 1, offvalue = 0, height=5,
width = 20,activebackground="red",bg="green")
C2=Checkbutton(top, text = "Video", variable = CheckVar2,
onvalue = 1, offvalue = 0, height=5,
width = 20)
C1.pack()
C2.pack()
B = Tkinter.Button(top, text ="Hello",activebackground="red",
,bd=3,bg="green",width=5) #Button
B.pack()
top.mainloop()
您是否嘗試過簡單地將關聯的變量設置爲零? –
是的,但它沒有工作.. –
它適用於我的代碼張貼在您的問題。我添加了一個調用「CheckVar1.set0」和「CheckVar2.set(0)」的函數,它工作得很好。當你說它不適合你時,請準確顯示你如何做,以及你得到的任何錯誤。 –