cursors.load_xbm requires two arguments
Saul Spatz, 2008-06-29 12:01:01 -0700
The documentation says that pygame.cursors.load_xbm has a default seconed argument of None. Not only is this not so, but the method will crash if given None as a second argument, since it will then call None.readlines(). I'm afraid I don't know enough about cursors to offer a patch, although is seems like setting the default to None and moving everything that relates to the mask inside an "if mask is not None:" guard might be all it takes.
Thorbrian, 2008-06-29 22:32:25 -0700
Saul, could you please provide a test case of some sort where you would want to call load_xbm without a mask argument?
It would be essential for me to be able to confirm correct behavior, as I don't know anything about xbm cursor files and how they are used. I can certainly code it to avoid an exception, but that's not sufficient - I need to code it to behave correctly.
If we can't find a way to confirm that calling load_xbm without a mask argument behaves correctly and is useful, then this bug will probably instead get resolved by changing the documentation.
Thomas Ibbotson, 2009-03-26 04:44:53 -0700
I just came across this bug when trying to make my own custom cursor. Here's what I've discovered.
load_xbm takes two arguments, which are files, or filelike objects. The first file is the data corresponding to the black pixels in the cursor, the second file (or maskfile) corresponds to the white pixels. All other pixels are transparent.
Perhaps you want a cursor which is all black and has no white (this wouldn't be a very good cursor as it might get obscured). In that case you might not want to pass an additional maskfile.
In any case the documentation is wrong as a maskfile of None causes an error. Also it states that maskfile is a keyword argument, which it is not.
I would suggest changing the documentation to say that the maskfile argument is a mandatory argument, as cursors with only black pixels should be avoided, but would still be possible by passing a maskfile with no bits set.
illume, 2009-05-27 00:40:58 -0700
Updated the documentation for this.
Committed revision 2268.