Hi! How can I detect when the active Image in the Image Editor has been changed? With the following code, loading a new image fires a change to the depsgraph, but not when I switch the image.
def get_active_image():
for area in bpy.context.screen.areas:
if area.type == 'IMAGE_EDITOR':
return area.spaces.active.image
@persistent
def depsgraph_update_post(scene, depsgraph):
if not depsgraph.id_type_updated('IMAGE'):
return
print(get_active_image())
if __name__ == "__main__":
bpy.app.handlers.depsgraph_update_post.append(depsgraph_update_post)
Unfortunately, if the depsgraph doesn’t register it, it’s not automatically detectable. Anything that is fires a depsgraph update. One potential workaround is to use a timer that checks the active image at intervals