Last active
October 14, 2015 14:57
-
-
Save internetimagery/e5ce59553cb22449ad58 to your computer and use it in GitHub Desktop.
animated image maya
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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