【问题标题】:Tkinter radiobutton indicatoron not recognisedTkinter 单选按钮指示器无法识别
【发布时间】:2014-08-06 11:33:06
【问题描述】:

我希望我的 Radiobuttons 使用本页中提到的按钮框界面,方法是设置 indicatoron=0:

http://effbot.org/tkinterbook/radiobutton.htm

代码sn-p:

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))

但是,当我运行我的代码时,我收到以下错误:

  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。

我的代码中是否缺少某些内容?

【问题讨论】:

    标签: python python-2.7 tkinter


    【解决方案1】:

    您链接的文档适用于 Tkinter.Radiobutton 类。您正在使用 ttk.Radiobutton 类,它不支持 indicatoron 属性。

    【讨论】:

      猜你喜欢
      • 2020-08-18
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 2015-04-21
      • 2015-07-04
      相关资源
      最近更新 更多