We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates


Previous topic

event_handling example code: poly_editor.py

Next topic

event_handling example code: resample.py

This Page

event_handling example code: pong_gtk.pyΒΆ

[source code]

#!/usr/bin/env python

from __future__ import print_function

# For detailed comments on animation and the techniques used here, see
# the wiki entry
# http://www.scipy.org/wikis/topical_software/MatplotlibAnimation
import time

import gtk, gobject

import matplotlib

import matplotlib.pyplot as plt
import pipong

fig, ax = plt.subplots()
canvas = ax.figure.canvas

def start_anim(event):
#    gobject.idle_add(animation.draw,animation)

animation = pipong.Game(ax)
start_anim.cid = canvas.mpl_connect('draw_event', start_anim)

tstart = time.time()
plt.grid() # to ensure proper background restore
print('FPS:' , animation.cnt/(time.time()-tstart))

Keywords: python, matplotlib, pylab, example, codex (see Search examples)