Skip to content

Instantly share code, notes, and snippets.

@internetimagery
Last active October 14, 2015 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save internetimagery/e5ce59553cb22449ad58 to your computer and use it in GitHub Desktop.
Save internetimagery/e5ce59553cb22449ad58 to your computer and use it in GitHub Desktop.
animated image maya
import time
import threading
import maya.cmds as cmds
import maya.utils as utils
class Animation(object):
def __init__(s, frames):
s.frames = frames
s.img = cmds.iconTextStaticLabel(style="iconOnly")
s.frame = 0
s.playing = False
s.limit = threading.Semaphore(1)
def tick(s):
try:
s.frame = s.frame - 1 if s.frame else len(s.frames)
cmds.iconTextStaticLabel(s.img, e=True, i=s.frames[s.frame])
except:
s.playing = False
finally:
s.limit.release()
def play(s):
if not s.playing:
def go():
while s.playing:
s.limit.acquire()
utils.executeDeferred(s.tick)
time.sleep(1)
s.playing = True
threading.Thread(target=go).start()
def stop(s):
s.playing = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment