Python Forum

Full Version: AttributeError
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using code to try to learn python. I am getting an AttributeError which I cannot figure out. Here is the error.

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "c:\Python\gui_cell_set_state.py", line 31, in _on_click
self.set_state(not self.active)
AttributeError: 'Cell' object has no attribute 'active'

I have copied the code exactly as it was written in the instructions and it seems to work until I try to Click on a box. That is the code presents the canvas with its boxes properly but when I try to click on a box to change its state, the error is thrown up. I cannot see what is causing this error. Would appreciate any help I could get. Thanks. The code is below.
david
Line 27: You've missed a dot:

self_active = False

Should be:
self._active = False
Please post code, not links.
(Jun-15-2023, 11:04 PM)rob101 Wrote: [ -> ]Line 27: You've missed a dot:

self_active = False

Should be:
self._active = False

Wow! is this language unforgiving. I did not see that at all. Thank you for helping me. Of course it is working fine now. Thanks again.
david
Those irritating programming languages that require you to write the code correctly for it to work.
(Jun-16-2023, 05:05 PM)foxxrunning Wrote: [ -> ]Wow! is this language unforgiving. I did not see that at all. Thank you for helping me. Of course it is working fine now. Thanks again.
david

You're welcome.
It's an all to easy mistake to make and not that easy to spot, as the error message really only hints at the issue, but as you become more experienced, you'll learn what to look for and where to look.