When you run these lines, is displayed this message:
Exception in thread Thread-6:
Traceback (most recent call last):
File "...\2.74\python\lib hreading.py", line 921, in _bootstrap_inner
self.run()
File "...\2.74\python\lib hreading.py", line 869, in run
self._target(*self._args, **self._kwargs)
File "...Bleder.blend\mano_music_player", line 50, in soundIsOn
AttributeError: pyrna_struct_meta_idprop_setattro() can't set in readonly state 'WindowManager.mano_music_timeline'
Does anyone know what this means?
The problem is this line (50):
“bpy.types.WindowManager.mano_music_timeline = bpy.props.IntProperty(min = 0, max = round(duration), subtype = ‘FACTOR’)”
One thing that jumps out at me is that you are trying to change bpy.types.WindowManager
“bpy.types.WindowManager” is a variable/attribute of the bpy.types module, it is a Python object, and theoretically the Python syntax lets you modify attributes on it. BUT it’s actually a class from which instances are created.
What you may actually want to use is bpy.context.window_manager. Without running that code in your blend file I can’t say if that is the solution, but it may be a step forward. In case the context is inaccessible, try bpy.data.window_managers[0]
Thank you @Bayesian. With bpy.context.window_manager and bpy.data.window_managers[0] I can change the current value of the property, but I can’t change its maximum value :(.
That’s what I’m trying to do with the line:
“bpy.types.WindowManager.mano_music_timeline = bpy.props.IntProperty(min = 0, max = round(duration), subtype = ‘FACTOR’)”
It might look strange to you, but that code is actually correct. This is how you define new properties on Blender ID types (such as Object, Mesh, but also WindowManager).
The error seems to occur because you’re trying to access Blender data from another thread. Don’t do that, it can crash Blender. See API Gotchas.