-1
どうすればいいですか? 私はエントリを取得したいが、このエラーは何ですか?tkinterの入力エラー
def gt():
global e
string = e.get()
print(string)
def p():
b.destroy()
c.destroy()
w = Label(top, text="here are what you can use:")
w1 = Label(top, text="qwertyuiop[]asdfghjkl;zxcvbnm,./QWERTYUIOPASDFGHJKLZXCVBNM123456789")
w.pack()
w1.pack()
L1 = Label(top, text="give me the password")
L1.pack(side = LEFT)
e=Entry(top)
e.pack()
r = Button(top,text='okay',command=gt)
r.pack(side='bottom')
top.mainloop()
エラー:
Traceback (most recent call last):
File "C:\Python33\lib\idlelib\run.py", line 121, in main
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
File "C:\Python33\lib\queue.py", line 175, in get
raise Empty
queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Hadi\Desktop\t.py", line 51, in gt
string = e.get()
NameError: global name 'e' is not defined
は、どのように私はこのコードを修正することができますか? eが定義されていますが、それは!!!!
'e'はグローバルに定義されていますが、クラスなどでは定義されていませんか?より多くのコードを表示する。 – kabanus
'e'を関数' p'の_local_変数として定義します –