开发者

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

开发者 https://www.devze.com 2023-01-20 08:09 出处:网络
What does the following error message mean? AttributeErro开发者_如何学Cr: \'NoneType\' object has no attribute \'tk\'

What does the following error message mean?

AttributeErro开发者_如何学Cr: 'NoneType' object has no attribute 'tk'


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()


It means that in your code some where you are calling

x.tk

and x is None (NoneType).

x should have been an object that is assumed to have an attribute tk.

To solve this problem, you can check out where you are obtaining x and see why it is not returning an appropriate object.


It means that variable to the left of .tk is None.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号