Let's say my UI looks like this:

enter image description here

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?

  • $\begingroup$ I would really like to know why my question downvoted this time? $\endgroup$ Nov 8, 2020 at 17:12

1 Answer 1


Find Image Editor views from screen.areas with filtering and call view_zoom_ratio operator with Overriding Context.

import bpy

override = bpy.context.copy()

for area in bpy.context.screen.areas:

    #if area.type != 'IMAGE_EDITOR' or area.ui_type != 'VIEW': # Image Editor View only
    #if area.type != 'IMAGE_EDITOR' or area.ui_type != 'UV': # UV Editor View only
    if area.type != 'IMAGE_EDITOR':

    area.spaces.active.show_region_header = False

    override['area'] = area
    bpy.ops.image.view_zoom_ratio(override, ratio=1.0)

  • $\begingroup$ First of all thank you for your time!!! To make it work I had to replace if area.type != 'IMAGE_EDITOR' or area.ui_type != 'VIEW': with if area.type == 'IMAGE_EDITOR': and remove the continue. Would you like to check it again and change it so to mark your answer as correct? $\endgroup$ Nov 8, 2020 at 10:02
  • 1
    $\begingroup$ Note that I used area.ui_type! ='VIEW' to exclude the UV Editor View. So my script works only on the Image Editor View. Do you want a script that works in UV Editor View as well as Image Editor View? $\endgroup$
    – tetii
    Nov 8, 2020 at 13:19
  • $\begingroup$ One "subquestion"! In case I have three image editors opened and for example I want to point the second one? $\endgroup$ Nov 14, 2020 at 9:18
  • $\begingroup$ You can make a new question. $\endgroup$
    – tetii
    Nov 14, 2020 at 11:46
  • $\begingroup$ I made it here blender.stackexchange.com/questions/201893/… $\endgroup$ Nov 14, 2020 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .