使用 Tkinter 的 Wing IDE 中的堆栈数据不正确?
Incorrect stack data in Wing IDE with Tkinter?
我正在使用 Wing 编写和调试 Tkinter GUI。我发现堆栈数据视图似乎与我的小部件的实际属性不匹配。以此代码为例:
import Tkinter
import ttk
root = Tkinter.Tk()
checkbutton = ttk.Checkbutton(root, text="Test Check Button")
print checkbutton.text
最后一行出现属性错误。但是,当我查看堆栈时,显然有一个名为 'text' 的属性具有我要查找的值:
有人知道怎么回事吗?
我正在使用:
- Wing 版本:Wing IDE Pro 5.1.3-1(修订版 33002)
- Tkinter 版本:“$修订版:81008 $”
- Python版本:2.7.10
你所说的属性不是对象属性。小部件使用内部系统来管理小部件选项。 .text
不是属性,这就是您收到错误的原因。要引用配置,请使用 .cget(...)
获取值并使用 .configure(...)
更改值。
我将其发布到 Wing 电子邮件列表,并收到开发人员的以下回复:
It looks like a ttk.Checkbutton
defines keys()
and __getitem__()
methods to exposes tk attributes via checkbutton[<name>]
. Because
of the keys()
and __getitem__()
, Wing is displaying the instance
as if it were a dictionary, with the keys and values interspersed with
the attributes. Wing does this because often you want to view an
object that defines keys()
and __getitem__()
as if it were a
dictionary, but I agree that it's confusing in this instance.
We'll try to improve this in a future release.
我正在使用 Wing 编写和调试 Tkinter GUI。我发现堆栈数据视图似乎与我的小部件的实际属性不匹配。以此代码为例:
import Tkinter
import ttk
root = Tkinter.Tk()
checkbutton = ttk.Checkbutton(root, text="Test Check Button")
print checkbutton.text
最后一行出现属性错误。但是,当我查看堆栈时,显然有一个名为 'text' 的属性具有我要查找的值:
有人知道怎么回事吗?
我正在使用:
- Wing 版本:Wing IDE Pro 5.1.3-1(修订版 33002)
- Tkinter 版本:“$修订版:81008 $”
- Python版本:2.7.10
你所说的属性不是对象属性。小部件使用内部系统来管理小部件选项。 .text
不是属性,这就是您收到错误的原因。要引用配置,请使用 .cget(...)
获取值并使用 .configure(...)
更改值。
我将其发布到 Wing 电子邮件列表,并收到开发人员的以下回复:
It looks like a
ttk.Checkbutton
defineskeys()
and__getitem__()
methods to exposes tk attributes viacheckbutton[<name>]
. Because of thekeys()
and__getitem__()
, Wing is displaying the instance as if it were a dictionary, with the keys and values interspersed with the attributes. Wing does this because often you want to view an object that defineskeys()
and__getitem__()
as if it were a dictionary, but I agree that it's confusing in this instance.We'll try to improve this in a future release.