我有一个简单的 python 程序,我想默认取消选中复选按钮。我希望以与用户取消选中复选框时相同的方式查看它。请让我知道如何实现它。
from tkinter import *
from tkinter import ttk
def urgentReq():
global box
state = box.state()
if(box.instate(['selected'])):
print ("--> Urgent: ",state)
else:
print ("--> Not Urgent:",state)
gui = Tk()
gui.title("GUI")
gui.geometry('200x150')
box = ttk.Checkbutton(gui, text ='Urgent Request', command=lambda: urgentReq())
box.grid(column=1, row=4, pady=40, sticky="N")
#write something here to unselect the box by default