1#!/usr/bin/env python 2# ---------------------------------------------------------------------------- 3# pyglet 4# Copyright (c) 2006-2008 Alex Holkner 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 11# * Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# * Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in 15# the documentation and/or other materials provided with the 16# distribution. 17# * Neither the name of pyglet nor the names of its 18# contributors may be used to endorse or promote products 19# derived from this software without specific prior written 20# permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33# POSSIBILITY OF SUCH DAMAGE. 34# ---------------------------------------------------------------------------- 35 36""" 37""" 38 39from __future__ import print_function 40 41__docformat__ = 'restructuredtext' 42__version__ = '$Id$' 43 44import pyglet 45from pyglet.window import key 46from pyglet.window import mouse 47 48window = pyglet.window.Window() 49 50 51@window.event 52def on_key_press(symbol, modifiers): 53 if symbol == key.A: 54 print('The "A" key was pressed.') 55 elif symbol == key.LEFT: 56 print('The left arrow key was pressed.') 57 elif symbol == key.ENTER: 58 print('The enter key was pressed.') 59 60 61@window.event 62def on_mouse_press(x, y, button, modifiers): 63 if button == mouse.LEFT: 64 print('The left mouse button was pressed.') 65 66 67@window.event 68def on_draw(): 69 window.clear() 70 71 72pyglet.app.run() 73