Pygame 1.9.2

Pygame Release 1.9.5.dev0 Release 1.9.5. 1.9.2.dev1 Subscribe to releases. Python Game Development Homepage PyPI. License Other Install. New in Pygame 1.8.1: BLENDRGBA. blitters and blenders to go with the BLENDRGB. blend modes. Documentation updates (mainly for new sprite classes released in 1.8.0). The mouse buttons generate pygame.MOUSEBUTTONDOWN and pygame.MOUSEBUTTONUP events when they are pressed and released. These events contain a button attribute representing which button was pressed. The mouse wheel will generate pygame.MOUSEBUTTONDOWN and pygame.MOUSEBUTTONUP events when rolled. The button will be set to 4 when the wheel is. Hashes for pygame-1.9.2-cp27-cp27mu-manylinux1x8664.whl. Hashes for pygame-1.9.2-cp27-cp27mu-manylinux1x8664.whl.

pygame.initinitialize all imported pygame modules
pygame.quituninitialize all pygame modules
pygame.errorstandard pygame exception
pygame.get_errorget the current error message
pygame.set_errorset the current error message
pygame.get_sdl_versionget the version number of SDL
pygame.get_sdl_byteorderget the byte order of SDL
pygame.register_quitregister a function to be called when pygame quits
pygame.encode_stringEncode a unicode or bytes object
pygame.encode_file_pathEncode a unicode or bytes object as a file system path

The pygame package represents the top-level package for others to use. Pygameitself is broken into many submodules, but this does not affect programs thatuse Pygame.

As a convenience, most of the top-level variables in pygame have been placedinside a module named ‘pygame.locals’. This is meant to be used with ‘from import *’, in addition to ‘import pygame’.

When you ‘import pygame’ all available pygame submodules are automaticallyimported. Be aware that some of the pygame modules are considered “optional”,and may not be available. In that case, Pygame will provide a placeholderobject instead of the module, which can be used to test for availability.

pygame.init()
init() -> (numpass, numfail)

Initialize all imported Pygame modules. No exceptions will be raised if amodule fails, but the total number if successful and failed inits will bereturned as a tuple. You can always initialize individual modules manually,but is a convenient way to get everything started. Theinit() functions for individual modules will raise exceptions when theyfail.

You may want to initalise the different modules seperately to speed up yourprogram or to not use things your game does not.

It is safe to call this init() more than once: repeated calls will haveno effect. This is true even if you have pygame.quit() all the modules.

pygame.quit()
quit() -> None

Uninitialize all pygame modules that have previously been initialized. Whenthe Python interpreter shuts down, this method is called regardless, so yourprogram should not need it, except when it wants to terminate its pygameresources and continue. It is safe to call this function more than once:repeated calls have no effect.

Note, that will not exit your program. Consider lettingyour program end in the same way a normal python program will end.

exception pygame.error
raise pygame.error(message)
Pygame-1.9.2b1-cp35-cp35m-win32.whl

This exception is raised whenever a pygame or SDL operation fails. Youcan catch any anticipated problems and deal with the error. The exception isalways raised with a descriptive message about the problem.

Derived from the RuntimeError exception, which can also be used to catchthese raised errors.

pygame.get_error()
get_error() -> errorstr

SDL maintains an internal error message. This message will usually begiven to you when is raised. You will rarely need tocall this function.

pygame.set_error()
set_error(error_msg) -> None

Pygame‑1.9.2a0‑cp35‑none‑win32.whl

SDL maintains an internal error message. This message will usually begiven to you when is raised. You will rarely need tocall this function.

pygame.get_sdl_version()
get_sdl_version() -> major, minor, patch

Returns the three version numbers of the SDL library. This version isbuilt at compile time. It can be used to detect which features may not beavailable through Pygame.

get_sdl_version is new in pygame 1.7.0

pygame.get_sdl_byteorder()
get_sdl_byteorder() -> int

Returns the byte order of the SDL library. It returns LIL_ENDIAN forlittle endian byte order and BIG_ENDIAN for big endian byte order.

get_sdl_byteorder is new in pygame 1.8

pygame.register_quit()
register a function to be called when pygame quits

When is called, all registered quit functions arecalled. Pygame modules do this automatically when they are initializing.This function is not be needed for regular pygame users.

pygame.encode_string()
encode_string([obj [, encoding [, errors [, etype]]]]) -> bytes or None

obj: If unicode, encode; if bytes, return unaltered; if anything else,return None; if not given, raise SyntaxError.

encoding (string): If present, encoding to use. The default is‘unicode_escape’.

errors (string): If given, how to handle unencodable characters. The defaultis ‘backslashreplace’.

etype (exception type): If given, the exception type to raise for anencoding error. The default is UnicodeEncodeError, as returned byPyUnicode_AsEncodedString(). For the default encoding and errors valuesthere should be no encoding errors.

This function is used in encoding file paths. Keyword arguments aresupported.

Added in Pygame 1.9.2 (primarily for use in unit tests)

pygame.encode_file_path()
Encode a unicode or bytes object as a file system path
encode_file_path([obj [, etype]]) -> bytes or None

obj: If unicode, encode; if bytes, return unaltered; if anything else,return None; if not given, raise SyntaxError.

etype (exception type): If given, the exception type to raise for anencoding error. The default is UnicodeEncodeError, as returned byPyUnicode_AsEncodedString().

Pygame

This function is used to encode file paths in Pygame. Encoding is to thecodec as returned by sys.getfilesystemencoding(). Keyword arguments aresupported.

Pygame 1.9.2 Download

Added in Pygame 1.9.2 (primarily for use in unit tests)