【发布时间】:2016-09-23 03:47:37
【问题描述】:
我已经浏览了现有的问题,但到目前为止我还没有找到解决方案。
我是 Python 编程语言的新手,已经开始使用 Tk,但在尝试“获取”值(从复选框)或更改标签值时不断收到以下错误消息:
“NoneType”对象没有属性“getitem”
以下是我在单击按钮时收到错误的代码示例
from Tkinter import *
the_window = Tk()
the_window.title('Button Change Colour')
def change_to_red():
colour_area['text']='Red'
colour_area = Label(the_window, bg='Grey', text = 'test', width = 40, height = 5).grid(row = 1, column = 1, padx = 5, pady = 5)
red_button = Button(the_window, text='Red', width = 5, command = change_to_red).grid(row = 2, column = 1)
the_window.mainloop()
我敢肯定这是一件小事/愚蠢的事情,但仍然感谢您的帮助! :)
【问题讨论】:
-
@AndrewL。是的,你当然是对的,^^ 那是链接到的规范。