1

を調べてきましたtkinkerget()関数を使用してテキスト ボックスから情報を取得するたびに、エラーが発生します。関数を使用すると、同じエラーが発生しfocus_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'
4

0 に答える 0