1. aquasheep
  2. pygame debug patch


pygame debug patch / docs / reST / ref / scrap.rst


EXPERIMENTAL!: meaning this api may change, or dissapear in later pygame releases. If you use this, your code will break with the next pygame release.

The scrap module is for getting and putting stuff from the clipboard. So you can copy and paste things between pygame, and other application types. It defines some basic own data types


to be placed into the clipboard and allows to use define own clipboard types. SCRAP_PPM, SCRAP_PBM and SCRAP_BMP are suitable for surface buffers to be shared with other applications, while SCRAP_TEXT is an alias for the plain text clipboard type.

The SCRAP_* types refer to the following MIME types and register those as well as the default operating system type for this type of data:

SCRAP_TEXT text/plain    for plain text
SCRAP_PBM  image/pbm     for PBM encoded image data
SCRAP_PPM  image/ppm     for PPM encoded image data
SCRAP_BMP  image/bmp     for BMP encoded image data

Depending on the platform additional types are automatically registered when data is placed into the clipboard to guarantee a consistent sharing behaviour with other applications. The following listed types can be used as string to be passed to the respective :mod:`pygame.scrap` module functions.

For Windows platforms, the additional types are supported automatically and resolve to their internal definitions:

text/plain;charset=utf-8 for UTF-8 encoded text
audio/wav                for WAV encoded audio
image/tiff               for TIFF encoded image data

For X11 platforms, the additional types are supported automatically and resolve to their internal definitions:

UTF8_STRING               for UTF-8 encoded text
text/plain;charset=utf-8  for UTF-8 encoded text
COMPOUND_TEXT             for COMPOUND text

As stated before you can define own types for the clipboard, those however might not be usable by other applications. Thus data pasted into the clipboard using

pygame.scrap.put ("own_data", data)

can only be used by applications, which query the clipboard for the "own_data" type.

New in pygame 1.8. Only works for Windows, X11 and Mac OS X so far. On Mac OSX only text works at the moment - other types will be supported in the next release.