# Play/animate images, spritesheets or video files in 'template_icon_view'

I want to "play" some animation in this UI space, the template_icon_view:

I can load all the images I want, for example:

I know that the gif format is not available.

I know the files with video format (.wmv, .mp4, .avi), can not be played, right?

Then I tested with sprite-sheet, but I can't select or split in each "frame":

Then I create operator that allow me change the image, but manually:

actual = wm["my_previews"]
total =wm["my_previews"]
contar=True
while contar:
wm["my_previews"] = wm["my_previews"] +1
if wm.my_previews == "":
contar = False
else:
total +=1

wm["my_previews"] = wm["my_previews"]
if avanzar and actual <total:
wm["my_previews"] = actual +1
elif (avanzar and actual == total):
wm["my_previews"] = 0
elif avanzar==False and actual>0:
wm["my_previews"] = actual -1
elif (avanzar==False and actual==0):
wm["my_previews"] =total



But I can not do this automatically, because I can not update the template_icon_view and all my tries crash blender.

while Play:

wm["my_previews"] = wm["my_previews"] +1

if wm.my_previews == "":
wm["my_previews"] =0
Play = False

time.sleep(0.5)

if self.Play:
z.start()
else:
z.stop()


I checked the Update options in different part of code and nothing works

bpy.context.view_layer.update()
dg =bpy.context.evaluated_depsgraph_get()
dg.update()


Any ideas? Maybe I'm in the wrong UI space to achieve my goal?

Actually, I was thinking of loading some blender files with the animations, but also I can't play that in the template_icon_view.

• Must it be looped endlessly? – Noob Cat Aug 4 '20 at 23:35
• @NoobCat I thought the same, but the blender interface is frozen until the process is finished – yhoyo Aug 5 '20 at 0:33
• You can create a separate thread for it. That is how game engines work. – Bruk Aug 9 '20 at 7:05
• I Don't want it for GE @Bruk. Actually do yo have Some code example? – yhoyo Aug 9 '20 at 13:22
• @yhoyo I was just saying game engines use that method they calculate physics and other stuff while animating. The reason blender's UI froze is because it have to finish drawing before it can update and since you are running an infinite loop it will never update thus it froze. If you call animate function which update the image and set a timer to call it based upon the frame rate of your animation you can get it working. Here is a link to about timers realpython.com/intro-to-python-threading/#timer. – Bruk Aug 12 '20 at 13:26