I'm trying to use a method of my class as application handler for when the scene's frame is changed. For that I'm using bpy.app.handlers.frame_change_pre.append(my_handler)
. My approach is the same as described on the Blender documentation with the difference that my function is a method of my class:
import bpy
class MyClass(object):
def my_handler(self, scene):
print("Frame Change", scene.frame_current)
my_object = MyClass()
bpy.app.handlers.frame_change_pre.append(my_object.my_handler)
However, I am getting this error message:
TypeError: my_handler() takes 2 positional arguments but 3 were given
When I do my_object.my_handler(bpy.data.scenes[0])
I correctly get the frame number whenever I change the keyframe.
Where am I going wrong?
Why does the function get 3 arguments passed?