pygame2.sdl.cursors – A module containing pre-defined mouse cursors

Set of cursor resources available for use. These cursors come in a sequence of values that are needed as the arguments for pygame2.sdl.mouse.set_cursor(). To dereference the sequence in place and create the cursor in one step, call like this:

pygame2.sdl.mouse.set_cursor(*pygame2.sdl.cursors.arrow).

Here is a list of available cursors:

  • arrow
  • diamond
  • ball
  • broken_x
  • tri_left
  • tri_right

There is also a sample string cursor named ‘thickarrow_strings’. The pygame2.sdl.cursors.compile() function can convert these string cursors into cursor byte data.

Module Functions

pygame2.sdl.cursors.compile(strings, black, white, xor) → data, mask

Compile cursor strings into cursor data.

This takes a set of strings with equal length and computes the binary data for that cursor. The string widths must be divisible by 8.

The black and white arguments are single letter strings that tells which characters will represent black pixels, and which characters represent white pixels. All other characters are considered clear.

This returns a tuple containing the cursor data and cursor mask data. Both these arguments are used when setting a cursor with pygame2.sdl.mouse.set_cursor().

pygame2.sdl.cursors.load_xbm(cursorfile, maskfile) → cursor_args

Reads a pair of XBM files into set_cursor arguments

Arguments can either be filenames or filelike objects with the readlines method. Not largely tested, but should work with typical XBM files.

Table Of Contents

Previous topic

pygame2.sdl.constants – Constants for SDL

Next topic

pygame2.sdl.event – SDL event wrapper

This Page