Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pygame Set Mouse Cursor from Bitmap

I'm making an image editor using pygame and I was wondering if it was possible to change the mouse cursor to something more suitable (for instance a circle or rectangle) for brushes. Pygame has a really weird way of doing it that I'm not sure would work very well. Is there a way I can write to a bitmap and then use that?

If there is a way to do it with Python generally, that would work too I suppose.

like image 417
SapphireSun Avatar asked Feb 27 '10 04:02

SapphireSun


2 Answers

Another option is to simply hide the cursor, load any arbitrary bitmap that you like and draw it every frame where the cursor is.

like image 97
Mizipzor Avatar answered Sep 28 '22 11:09

Mizipzor


You can load cursors in PyGame with pygame.cursors.load_xbm -- that's black and white cursors only, of course, a well-documented limitation of PyGame, per its docs (and I quote):

Pygame only supports black and white cursors for the system.

For XBM format docs, see e.g. here. You can prep such files e.g. with the PIL library, per its docs.

like image 43
Alex Martelli Avatar answered Sep 28 '22 11:09

Alex Martelli