O'Reilly logo

Python Multimedia Beginner's Guide by Ninad Sathaye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - viewing an existing animation

This is going to be a short exercise. The goal of this section is to develop a primary understanding on use of Pyglet for viewing animations. So let's get on with it.

  1. Download the file SimpleAnimation.py from the Packt website. Also download the file SimpleAnimation.gif and place it in a sub-directory images. The code is illustrated as follows:
    1 import pyglet 2 3 animation = pyglet.image.load_animation( 4 "images/SimpleAnimation.gif") 5 6 # Create a sprite object as an instance of this animation. 7 animSprite = pyglet.sprite.Sprite(animation) 8 9 # The main pyglet window with OpenGL context 10 w = animSprite.width 11 h = animSprite.height 12 win = pyglet.window.Window(width=w, height=h) 13 14 # r,g ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required