.get函数上的Python tkinker 3.0非类型错误
我一直在研究.get函数上的Python tkinker 3.0非类型错误,python,nonetype,Python,Nonetype,我一直在研究tkinker。每当我使用get()函数从文本框中获取信息时,就会出现错误。使用focus\u set()函数时,我也会遇到同样的错误 这是我的密码: from tkinter import * root = Tk() root.title("Super Awsome Mega Pi") Label(root, text="What's Your Name?", fg="red").pack() def destroy(): root.destroy() def button
tkinker
。每当我使用get()
函数从文本框中获取信息时,就会出现错误。使用focus\u set()
函数时,我也会遇到同样的错误
这是我的密码:
from tkinter import *
root = Tk()
root.title("Super Awsome Mega Pi")
Label(root, text="What's Your Name?", fg="red").pack()
def destroy():
root.destroy()
def button2():
name = str(input1.get())
print(name)
n = Button(root, text="Enter", command = button2).pack(side=LEFT)
input1 = Entry(root).pack(side=LEFT)
q = Button(root, text="Quit", command = destroy).pack(side=LEFT)
input1.focus_set()
def color():
root["bg"] = input1.get()
c = Button(root, text="Change Color", command = color).pack()
root.mainloop()
任何帮助都会很好。我知道这是我写的代码,不是别的。如果有帮助,这就是它抛出的错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1442, in __call__
return self.func(*args)
File "C:/Users/Kie/Documents/Computing/tkinter test.py", line 12, in button2
name = str(input1.get())
AttributeError: 'NoneType' object has no attribute 'get'