[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Cursor update



Ok, as promised I've got the cursor module all featured up.

First, there is a small list of generic cursors provided
in the pygame.cursors module. Here is the list;
arrow, diamond, ball, broken_x, tri_left, tri_right

as a bonus, the diamond cursor now works correctly. (you can
see it in the fonty example)


Also new to the cursor module are two new cursor creating
functions. The first, "read_xbm(cursor, mask)" takes two 
filenames (or file-like objects). This should server your
needs loading and converting from the standard xwindows 
cursor format. The other function, "compile(strings)" takes
a sequence of strings representing cursor bit data. The 
cursor module comes with a set of cursor strings named
"thickarrow_strings". Here is code you would use yourself
to create this cursor, compile it, and set it as the current
cursor....

#draw the cursor
my_cursor_str = (
  "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               ",
  "                        ",
  "                        ",
  "                        ",
)
#compile the cursor
my_cursor = pygame.cursor.compile(cursor_str)
#set as current
pygame.mouse.set_cursor((24, 24), (0, 0), *my_cursor)



as you can see, it's pretty basic, but it certainly does
its job. btw, the argument "*my_cursor" is a new python 2.0
syntax, and it means to expand the items in a sequence to
arguments for a function. it could also be called;
pygame.mouse.set_cursor(24, 24), (0, 0), my_cursor[0], my_cursor[1])
but, BAH! (there, you learned something new about python today :] )

this is all checked into cvs, go forth and tinker.


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org