1. pygame
  2. pygame
  3. pygame


pygame / docs / ref / pygame.html

<title>pygame - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>

<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</a>&nbsp;||&nbsp;
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
<a href="display.html">Display</a>&nbsp;||&nbsp;
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
<a href="event.html">Event</a>&nbsp;||&nbsp;
<a href="examples.html">Examples</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
<a href="image.html">Image</a>&nbsp;||&nbsp;
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
<a href="key.html">Key</a>&nbsp;||&nbsp;
<a href="locals.html">Locals</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="midi.html">Midi</a>&nbsp;||&nbsp;
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
<a href="music.html">Music</a>&nbsp;||&nbsp;
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
<a href="tests.html">Tests</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>

<a name="pygame">
  <i>the top level pygame package</i><br>
  <tr><td><a href="pygame.html#pygame.init">pygame.init</a> - <font size=-1>initialize all imported pygame modules</font></td><td>initialize all imported pygame modules</td></tr>
  <tr><td><a href="pygame.html#pygame.quit">pygame.quit</a> - <font size=-1>uninitialize all pygame modules</font></td><td>uninitialize all pygame modules</td></tr>
  <tr><td><a href="pygame.html#pygame.error">pygame.error</a> - <font size=-1>standard pygame exception</font></td><td>standard pygame exception</td></tr>
  <tr><td><a href="pygame.html#pygame.get_error">pygame.get_error</a> - <font size=-1>get the current error message</font></td><td>get the current error message</td></tr>
  <tr><td><a href="pygame.html#pygame.set_error">pygame.set_error</a> - <font size=-1>set the current error message</font></td><td>set the current error message</td></tr>
  <tr><td><a href="pygame.html#pygame.get_sdl_version">pygame.get_sdl_version</a> - <font size=-1>get the version number of SDL</font></td><td>get the version number of SDL</td></tr>
  <tr><td><a href="pygame.html#pygame.get_sdl_byteorder">pygame.get_sdl_byteorder</a> - <font size=-1>get the byte order of SDL</font></td><td>get the byte order of SDL</td></tr>
  <tr><td><a href="pygame.html#pygame.register_quit">pygame.register_quit</a> - <font size=-1>register a function to be called when pygame quits</font></td><td>register a function to be called when pygame quits</td></tr>
  <tr><td><a href="pygame.html#pygame.version">pygame.version</a> - <font size=-1>small module containing version information</font></td><td>small module containing version information</td></tr>
<p>The pygame package represents the top-level package for others to use. Pygame itself is broken into many submodules, but this does not affect programs that use Pygame. </p>
<p>As a convenience, most of the top-level variables in pygame have been placed inside a module named <tt>'pygame.locals'</tt>. This is meant to be used with 'from <tt>pygame.locals</tt> import *', in addition to 'import pygame'. </p>
<p>When you 'import pygame' all available pygame submodules are automatically imported. Be aware that some of the pygame modules are considered "optional", and may not be available. In that case, Pygame will provide a placeholder object instead of the module, which can be used to test for availability. </p>
<!--COMMENTS:pygame--> &nbsp;<br> 

<a name="pygame.init">
  <i>initialize all imported pygame modules</i><br>
  <tt>pygame.init(): return (numpass, numfail)</tt><br>
<p>Initialize all imported Pygame modules. No exceptions will be raised if a module fails, but the total number if successful and failed inits will be returned as a tuple. You can always initialize individual modules manually, but <tt>pygame.init</tt> is a convenient way to get everything started. The init() functions for individual modules will raise exceptions when they fail. </p>
<p>You may want to initalise the different modules seperately to speed up your program or to not use things your game does not. </p>
<p>It is safe to call this init() more than once: repeated calls will have no effect. This is true even if you have <tt><a href="pygame.html#pygame.quit">pygame.quit</a> - <font size=-1>uninitialize all pygame modules</font></tt> all the modules. </p>
<!--COMMENTS:pygame.init--> &nbsp;<br> 

<a name="pygame.quit">
  <i>uninitialize all pygame modules</i><br>
  <tt>pygame.quit(): return None</tt><br>
<p>Uninitialize all pygame modules that have previously been initialized. When the Python interpreter shuts down, this method is called regardless, so your program should not need it, except when it wants to terminate its pygame resources and continue. It is safe to call this function more than once: repeated calls have no effect. </p>
<p>Note, that <tt>pygame.quit</tt> will not exit your program. Consider letting your program end in the same way a normal python program will end. </p>
<!--COMMENTS:pygame.quit--> &nbsp;<br> 

<a name="pygame.error">
  <i>standard pygame exception</i><br>
  <tt>raise pygame.error, message</tt><br>
<p>This exception is raised whenever a pygame or <tt>SDL</tt> operation fails. You can catch any anticipated problems and deal with the error. The exception is always raised with a descriptive message about the problem. </p>
<p>Derived from the RuntimeError exception, which can also be used to catch these raised errors. </p>
<!--COMMENTS:pygame.error--> &nbsp;<br> 

<a name="pygame.get_error">
  <i>get the current error message</i><br>
  <tt>pygame.get_error(): return errorstr</tt><br>
<p><tt>SDL</tt> maintains an internal error message. This message will usually be given to you when <tt>pygame.error</tt> is raised. You will rarely need to call this function. </p>
<!--COMMENTS:pygame.get_error--> &nbsp;<br> 

<a name="pygame.set_error">
  <i>set the current error message</i><br>
  <tt>pygame.set_error(error_msg): return None</tt><br>
<p><tt>SDL</tt> maintains an internal error message. This message will usually be given to you when <tt>pygame.error</tt> is raised. You will rarely need to call this function. </p>
<!--COMMENTS:pygame.set_error--> &nbsp;<br> 

<a name="pygame.get_sdl_version">
  <i>get the version number of SDL</i><br>
  <tt>pygame.get_sdl_version(): return major, minor, patch</tt><br>
<p>Returns the three version numbers of the <tt>SDL</tt> library. This version is built at compile time. It can be used to detect which features may not be available through Pygame. </p>
<p>get_sdl_version is new in pygame <tt>1.7.0</tt> </p>
<!--COMMENTS:pygame.get_sdl_version--> &nbsp;<br> 

<a name="pygame.get_sdl_byteorder">
  <i>get the byte order of SDL</i><br>
  <tt>pygame.get_sdl_byteorder(): return int</tt><br>
<p>Returns the byte order of the <tt>SDL</tt> library. It returns <tt>LIL_ENDIAN</tt> for little endian byte order and <tt>BIG_ENDIAN</tt> for big endian byte order. </p>
<p>get_sdl_byteorder is new in pygame <tt>1.8</tt> </p>
<!--COMMENTS:pygame.get_sdl_byteorder--> &nbsp;<br> 

<a name="pygame.register_quit">
  <i>register a function to be called when pygame quits</i><br>
  <tt>register_quit(callable): return None</tt><br>
<p>When <tt>pygame.quit</tt> is called, all registered quit functions are called. Pygame modules do this automatically when they are initializing. This function is not be needed for regular pygame users. </p>
<!--COMMENTS:pygame.register_quit--> &nbsp;<br> 

<a name="pygame.version">
  <i>small module containing version information</i><br>
  <tt>module pygame.version</tt><br>
  <tr><td><a href="pygame.html#pygame.version.ver">pygame.version.ver</a> - <font size=-1>version number as a string</font></td><td>version number as a string</td></tr>
  <tr><td><a href="pygame.html#pygame.version.vernum">pygame.version.vernum</a> - <font size=-1>tupled integers of the version</font></td><td>tupled integers of the version</td></tr>
<p>This module is automatically imported into the pygame package and offers a few variables to check with version of pygame has been imported. </p>
<!--COMMENTS:pygame.version--> &nbsp;<br> 

<a name="pygame.version.ver">
  <i>version number as a string</i><br>
  <tt>pygame.version.ver = '1.2'</tt><br>
<p>This is the version represented as a string. It can contain a micro release number as well, <tt>e.g.</tt>, <tt>'1.5.2'</tt> </p>
<!--COMMENTS:pygame.version.ver--> &nbsp;<br> 

<a name="pygame.version.vernum">
  <i>tupled integers of the version</i><br>
  <tt>pygame.version.vernum = (1, 5, 3)</tt><br>
<p>This variable for the version can easily be compared with other version numbers of the same format. An example of checking Pygame version numbers would look like this: </p>
<pre>    if pygame.version.vernum < (1, 5):
        print 'Warning, older version of Pygame (%s)' %  pygame.version.ver
        disable_advanced_features = True
<!--COMMENTS:pygame.version.vernum--> &nbsp;<br>