Skip to content
Advertisement

attributeError when calling method of object class

JavaScript

Trying to animate a car with button to accelerate and decelerate. When I press a button to accelerate/decelerate, I get an error in the ‘if’ statements on both methods “AttributeError: ‘bool’ object has no attribute ‘speed'”. Can someone help me figure out what’s going wrong? Thank you!

Advertisement

Answer

You should pass to clicked.connect a method bound to the object in question instead of the unbound method Car.accelerate:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement