AttributeError - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: AttributeError (/thread-40184.html) |
AttributeError - foxxrunning - Jun-15-2023 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 RE: AttributeError - rob101 - Jun-15-2023 Line 27: You've missed a dot: self_active = False Should be: self._active = False
RE: AttributeError - deanhystad - Jun-16-2023 Please post code, not links. RE: AttributeError - foxxrunning - Jun-16-2023 (Jun-15-2023, 11:04 PM)rob101 Wrote: Line 27: You've missed a dot: 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 RE: AttributeError - deanhystad - Jun-16-2023 Those irritating programming languages that require you to write the code correctly for it to work. RE: AttributeError - rob101 - Jun-16-2023 (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. 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. |