Python,Tkinter。如何检查小部件ttk.CheckButton?

问题描述 投票:0回答:2

与TC不同的ttk版本不支持inter .SELECT()的方法

tkinter ttk
2个回答
1
投票

ttk Checkbutton Guide说,这是一个快速的谷歌搜索

不支持Tkinter Checkbutton小部件的以下方法:.deselect(),. makeh(),. select()和.toggle()。要通过程序控制更改检查按钮的状态,请使用关联控制变量的.set()方法。

还有.invoke(),但也会调用命令,因此在调用invoke之后你必须将函数赋值给命令


0
投票

使用ttk在Python3 tkinter中创建一个Checkbutton:

# create the button
self.check_example =  ttk.Checkbutton(self, text = "Checked")
# invoke "checks" the button
self.check_example.invoke()
# grid is one of the ways to display the button
self.check_example.grid(row=2,column=0, sticky=W)
© www.soinside.com 2019 - 2024. All rights reserved.