Let's say my UI looks like this:
What I want to do is to change some Image Editor bpy.context.window_manager.windows[0].screen.areas[1]
options through my addon. For example, to change the image of Image Editor I do sometihng like this:
texture_name = "face.png"
area = bpy.context.window_manager.windows[0].screen.areas[1]
area.spaces.active.image = bpy.data.images[texture_name]
In case I want to change, let's say the header of Image Editor. If it will appear or not. Or the zoom ratio of the image. How I'll do that?
I found this bpy.context.space_data.show_region_header = False
and this bpy.ops.image.view_zoom_ratio(ratio=1.0)
using right click, but I don't know how to use it. Because for example if I use bpy.context.space_data.show_region_header = False
from my addon, it will not hide Image Editor's header but 3D Viewport's header.
I also try to iterate through areas and do bpy.context.space_data.show_region_header = False
and bpy.ops.image.view_zoom_ratio(ratio=1.0)
from there. But I can't find the syntax. Because for example, bpy.ops.image.view_zoom_ratio(ratio=1.0)
should be something like area.spaces.view_zoom_ratio(ratio=1.0)
. Which doesn't work and gives me this error AttributeError: 'bpy_prop_collection' object has no attribute 'view_zoom_ratio'
So, any idea how can I do this?