File: cursors.doc

package info (click to toggle)
pygame 1.8.1release-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,476 kB
  • ctags: 4,574
  • sloc: ansic: 28,660; python: 13,523; makefile: 61; sh: 1
file content (107 lines) | stat: -rwxr-xr-x 3,744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
pygame.cursors
pygame module for cursor resources

Pygame offers control over the system hardware cursor. Pygame only supports
black and white cursors for the system. You control the cursor with functions
inside pygame.mouse.

This cursors module contains functions for loading and unencoding various cursor
formats. These allow you to easily store your cursors in external files or
directly as encoded python strings.

The module includes several standard cursors. The pygame.mouse.set_cursor()
function takes several arguments. All those arguments have been stored in a
single tuple you can call like this:

   >>> pygame.mouse.set_cursor(*pygame.cursors.arrow)
   
This module also contains a few cursors as formatted strings. You'll need to
pass these to pygame.cursors.compile() function before you can use them. The
example call would look like this:

   >>> cursor = pygame.cursors.compile(pygame.cursors.textmarker_strings)
   >>> pygame.mouse.set_cursor(*cursor)

The following variables are cursor bitmaps that can be used as cursor:

*        pygame.cursors.arrow
*        pygame.cursors.diamond
*        pygame.cursors.broken_x
*        pygame.cursors.tri_left
*        pygame.cursors.tri_right

The following strings can be converted into cursor bitmaps with
pygame.cursors.compile() :

*        pygame.cursors.thickarrow_strings
*        pygame.cursors.sizer_x_strings
*        pygame.cursors.sizer_y_strings
*        pygame.cursors.sizer_xy_strings
<SECTION>



compile
create binary cursor data from simple strings
pygame.cursor.compile(strings, black='X', white='.', xor='o'): return data, mask

A sequence of strings can be used to create binary cursor data for the system
cursor. The return values are the same format needed by
pygame.mouse.set_cursor().

If you are creating your own cursor strings, you can use any value represent the
black and white pixels. Some system allow you to set a special toggle color for
the system color, this is also called the xor color. If the system does not
support xor cursors, that color will simply be black.

The width of the strings must all be equal and be divisible by 8. An example set
of cursor strings looks like this

    thickarrow_strings = (               #sized 24x24
      "XX                      ",
      "XXX                     ",
      "XXXX                    ",
      "XX.XX                   ",
      "XX..XX                  ",
      "XX...XX                 ",
      "XX....XX                ",
      "XX.....XX               ",
      "XX......XX              ",
      "XX.......XX             ",
      "XX........XX            ",
      "XX........XXX           ",
      "XX......XXXXX           ",
      "XX.XXX..XX              ",
      "XXXX XX..XX             ",
      "XX   XX..XX             ",
      "     XX..XX             ",
      "      XX..XX            ",
      "      XX..XX            ",
      "       XXXX             ",
      "       XX               ",
      "                        ",
      "                        ",
      "                        ")
<END>



load_xbm
load cursor data from an xbm file
pygame.cursors.load_xbm(cursorfile, maskfile=None): return cursor_args

This loads cursors for a simple subset of XBM files. XBM files are traditionally
used to store cursors on unix systems, they are an ascii format used to
represent simple images.

Sometimes the black and white color values will be split into two separate XBM
files. You can pass a second maskfile argument to load the two images into a
single cursor.

The cursorfile and maskfile arguments can either be filenames or filelike object
with the readlines method.

The return value cursor_args can be passed directly to the
pygame.mouse.set_cursor() function.
<END>
<END>