I've created this simple GUI:
from tkinter import *
root = Tk()
def grabText(event):
print(entryBox.get())
entryBox = Entry(root, width=60).grid(row=2, column=1, sticky=W)
grabBtn = Button(root, text="Grab")
grabBtn.grid(row=8, column=1)
grabBtn.bind('<Button-1>', grabText)
root.mainloop()
I get the UI up and running. When I click on the Grab
button, I get the following error on the console:
C:Python> python.exe myFilesestBed.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:Pythonliblib-tkTkinter.py", line 1403, in __call__
return self.func(*args)
File "myFilesestBed.py", line 10, in grabText
if entryBox.get().strip()=="":
AttributeError: 'NoneType' object has no attribute 'get'
Why is entryBox
set to None
?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…