I want to detect context changes when switching between different tabs in the property editor.
How should I set up msgbus or how to get the context through the Python API?
import bpy
# Any Python object can act as the subscription's owner.
owner = object()
subscribe_to = bpy.types.SpaceProperties, 'context'
def msgbus_callback(*args):
print(args)
current_tab = bpy.context.screen.areas[0].spaces.active.context
print(f'Current Tab: {current_tab}')
bpy.msgbus.subscribe_rna(
key=subscribe_to,
owner=owner,
args=(1, 2, 3),
notify=msgbus_callback,
)