Blender Python: How to activate the Auto Refresh in a imported sequence on Image Editor? I'm developing a way to import DICOM slices on Blender. All works well, but I'm with dificults to activate the Auto Refresh after import the sequence:



I really read a lot of examples and the documentation, but the data is different of other commands. I cannot acess it:

import bpy
import os


def ImportaSeqTomoDef(self, context):

    layout = self.layout
    scn = context.scene
    obj = context.object 

    IMGDir = str(bpy.types.Scene.IMGPathSeq[1]['default'])

    ListaArquivos = sorted(os.listdir(IMGDir))

    listaIMG=[]

    for Arquivo in ListaArquivos:
        listaIMG.append( {"name":Arquivo, "name":Arquivo} )

    print(listaIMG)

    bpy.ops.image.open(directory=IMGDir, files=listaIMG, relative_path=True, show_multiview=False)
    bpy.data.images[str(ListaArquivos[0])].source = 'SEQUENCE'


#    bpy.data.screens["Default"]..use_auto_refresh = True 

class ImportaSeqTomo(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.importa_img_tomo"
    bl_label = "Teste"

    def execute(self, context):
        ImportaSeqTomoDef(self, context)
        return {'FINISHED'}


Thanks for the attention!
Digging for classes and properties.

If you right click and view source on checkbox you see,

def draw(self, context):
    layout = self.layout

    sima = context.space_data
    iuser = sima.image_user

    layout.template_image(sima, "image", iuser, multiview=True)


which gives a clue that it belongs to the image editor space sima and there is a class  ImageUser instance sima.image_user... 

Ok off to py console, making sure an image editor is open in same screen, in case below its in area 1

&gt;&gt;&gt; for i, a in enumerate(C.screen.areas):
...     i, a.type
...     
(0, 'INFO')
(1, 'IMAGE_EDITOR')
(2, 'CONSOLE')
(3, 'VIEW_3D')
(4, 'TEXT_EDITOR')

&gt;&gt;&gt; sp = C.screen.areas[1].spaces.active
&gt;&gt;&gt; sp.image_user.use_auto_refresh
False


Hence in your operator, as long as it is invoked from the image editor you can set with

space = context.space_data
space.image_user.use_auto_refresh = True


This is an example of

SpaceImageEditor.image_user


See the reference section of manual https://docs.blender.org/api/2.79/bpy.types.ImageUser.html?highlight=use_auto_refresh#bpy.types.ImageUser.use_auto_refresh for other possible references.

BackgroundImage.image_user
EnvironmentMapTexture.image_user
Image.filepath_from_user
ImageTexture.image_user
Object.image_user
ShaderNodeTexEnvironment.image_user
ShaderNodeTexImage.image_user    
TextureNodeImage.image_user
UILayout.template_image
UILayout.template_image_layers
VoxelDataTexture.image_user