无法识别 Tkinter 单选按钮指示器 [英] Tkinter radiobutton indicatoron not recognised
问题描述
我希望我的 Radiobuttons 使用本页提到的按钮框界面,通过设置 indicatoron=0:
I'd like my Radiobuttons to use the button box interface as mentioned on this page, by setting indicatoron=0:
http://effbot.org/tkinterbook/radiobutton.htm
代码片段:
import ttk
...
self.selectedSectionCode = StringVar()
self.selectedSectionCode.set("abc")
abcButton = ttk.Radiobutton(self, text='ABC', variable=self.selectedSectionCode, value='abc', indicatoron= 0)
abcButton.grid(column=0, row=1, sticky=(N,W))
但是,当我运行代码时,出现以下错误:
However when I run my code I get the following error:
File "C:\Users\...\view.py", line 473, in __init__
abcButton = ttk.Radiobutton(self, text='ABC', value='abc', indicatoron = 0)
File "C:\Python27\lib\lib-tk\ttk.py", line 1073, in __init__
Widget.__init__(self, master, "ttk::radiobutton", kw)
File "C:\Python27\lib\lib-tk\ttk.py", line 560, in __init__
Tkinter.Widget.__init__(self, master, widgetname, kw=kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1974, in __init__
(widgetName, self._w) + extra + self._options(cnf))
clError: unknown option "-indicatoron"
我不知道为什么这不起作用,并且这个站点上有几个例子提到了 Radiobutton 小部件使用的这个选项,用户也使用 Python 2.7.
I'm not sure why this is not working, and there are several examples on this site which mention this option used by the Radiobutton widget, by users who are also using Python 2.7.
我的代码中是否缺少某些内容?
Is there something missing in my code?
推荐答案
您链接的文档适用于 Tkinter.Radiobutton
类.您正在使用 ttk.Radiobutton
类,该类不支持indicatoron
属性.
The documentation you linked is for the Tkinter.Radiobutton
class. You are using the ttk.Radiobutton
class, which does not support an indicatoron
attribute.
这篇关于无法识别 Tkinter 单选按钮指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!