私はPython Tkinterについて何かを学んでおり、次の簡単なコードを書きました:
from Tkinter import *
import tkMessageBox
def print_it(msg):
Text1.insert(INSERT, str(msg))
top = Tk()
Entry1 = Entry(width=300)
Entry1.pack(side='top')
Button1 = Button(text='Send',width=300,command=print_it("Message"))
Button1.pack(side='top')
Text1 = Text(height=600,width=300)
Text1.pack(side='top')
top.geometry('640x480+10+10')
top.title('GUI')
top.mainloop()
理由はわかりませんが、次のエラーが表示されます。
NameError: グローバル名 'Text1' が定義されていません
Text1
print_it 定義 の を に置き換えEntry1
ても、エラーは発生しません。