비슷한 오류 메시지에 대한 다른 게시물을 보았지만 제 경우에 해결할 해결책을 찾지 못했습니다.Tkinter : AttributeError : NoneType 객체에 속성이 없습니다.
나는 TkInter를 조금 뜯어보고 아주 간단한 UI를 만들었습니다. 코드는 다음과 같습니다 :
from string import *
from Tkinter import *
import tkMessageBox
root=Tk()
vid = IntVar()
def grabText(event):
if entryBox.get().strip()=="":
tkMessageBox.showerror("Error", "Please enter text")
else:
print entryBox.get().strip()
root.title("My Sample")
root.maxsize(width=550, height=200)
root.minsize(width=550, height=200)
root.resizable(width=NO, height=NO)
label=Label(root, text = "Enter text:").grid(row=2,column=0,sticky=W)
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()
나는 UI를 실행하고 있습니다. 나는 Grab
버튼을 클릭하면, 나는 콘솔에 다음과 같은 오류가 발생합니다 :
C:\Python25>python.exe myFiles\testBed.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
return self.func(*args)
File "myFiles\testBed.py", line 10, in grabText
if entryBox.get().strip()=="":
AttributeError: 'NoneType' object has no attribute 'get'
오류는 Tkinter.py
다시 추적합니다.
이전에이 문제를 처리했을 수도 있습니다. 어떤 도움을 주셔서 감사합니다.
자세한 내용 [** 여기 **] (https://www.begueradj.com/tkinter-saya-idiom.html) –