Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

python - Meaning of "AttributeError: NoneType object has no attribute tk"?

What does the following error message mean?

AttributeError: 'NoneType' object has no attribute 'tk'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have had this problem but found the solution. This problem arises when you declare the variable before you make an instance of Tk().

For example, this will bring the error

count = IntVar()
....
....
app = Tk()

Solution!! Make the declarations after creating a tkinter application window

app = Tk()
....
count = IntVar()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...