pygame / docs / ref / cursors.html

<html>
<title>cursors - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</a>&nbsp;||&nbsp;
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
<a href="display.html">Display</a>&nbsp;||&nbsp;
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
<a href="event.html">Event</a>&nbsp;||&nbsp;
<a href="examples.html">Examples</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
<a href="image.html">Image</a>&nbsp;||&nbsp;
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
<a href="key.html">Key</a>&nbsp;||&nbsp;
<a href="locals.html">Locals</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="midi.html">Midi</a>&nbsp;||&nbsp;
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
<a href="music.html">Music</a>&nbsp;||&nbsp;
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
<a href="tests.html">Tests</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>
</td></tr></table>
<br>


<a name="pygame.cursors">
<big><b>pygame.cursors</big></b><br><ul>
  <i>pygame module for cursor resources</i><br>
<ul><small><table>
  <tr><td><a href="cursors.html#pygame.cursors.compile">pygame.cursors.compile</a> - <font size=-1>create binary cursor data from simple strings</font></td><td>create binary cursor data from simple strings</td></tr>
  <tr><td><a href="cursors.html#pygame.cursors.load_xbm">pygame.cursors.load_xbm</a> - <font size=-1>load cursor data from an xbm file</font></td><td>load cursor data from an xbm file</td></tr>
</table></small></ul>
<p>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 <tt>pygame.mouse</tt>. </p>
<p>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. </p>
<p>The module includes several standard cursors. The <tt><a href="mouse.html#pygame.mouse.set_cursor">pygame.mouse.set_cursor</a> - <font size=-1>set the image for the system mouse cursor</font></tt> function takes several arguments. All those arguments have been stored in a single tuple you can call like this: </p>
<pre>   >>> pygame.mouse.set_cursor(*pygame.cursors.arrow)
</pre><p>This module also contains a few cursors as formatted strings. You'll need to pass these to <tt><a href="cursors.html#pygame.cursors.compile">pygame.cursors.compile</a> - <font size=-1>create binary cursor data from simple strings</font></tt> function before you can use them. The example call would look like this: </p>
<pre>   >>> cursor = pygame.cursors.compile(pygame.cursors.textmarker_strings)
   >>> pygame.mouse.set_cursor(*cursor)
</pre><p>The following variables are cursor bitmaps that can be used as cursor: </p>
<ul>
 <li><tt>        pygame.cursors.arrow </tt></li>
 <li><tt>        pygame.cursors.diamond </tt></li>
 <li><tt>        pygame.cursors.broken_x </tt></li>
 <li><tt>        pygame.cursors.tri_left </tt></li>
 <li><tt>        pygame.cursors.tri_right </tt></li>
</ul>
<p>The following strings can be converted into cursor bitmaps with <tt><a href="cursors.html#pygame.cursors.compile">pygame.cursors.compile</a> - <font size=-1>create binary cursor data from simple strings</font></tt> : </p>
<ul>
 <li><tt>        pygame.cursors.thickarrow_strings </tt></li>
 <li><tt>        pygame.cursors.sizer_x_strings </tt></li>
 <li><tt>        pygame.cursors.sizer_y_strings </tt></li>
 <li><tt>        pygame.cursors.sizer_xy_strings </tt></li>
</ul>
<!--COMMENTS:pygame.cursors--> &nbsp;<br> 


<a name="pygame.cursors.compile">
<big><b>pygame.cursors.compile</big></b><br><ul>
  <i>create binary cursor data from simple strings</i><br>
  <tt>pygame.cursor.compile(strings, black='X', white='.', xor='o'): return data, mask</tt><br>
<p><tt>A</tt> sequence of strings can be used to create binary cursor data for the system cursor. The return values are the same format needed by <tt><a href="mouse.html#pygame.mouse.set_cursor">pygame.mouse.set_cursor</a> - <font size=-1>set the image for the system mouse cursor</font></tt>. </p>
<p>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. </p>
<p>The width of the strings must all be equal and be divisible by 8. An example set of cursor strings looks like this </p>
<pre>    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               ",
      "                        ",
      "                        ",
      "                        ")
</pre>
<!--COMMENTS:pygame.cursors.compile--> &nbsp;<br> 
<br></ul>


<a name="pygame.cursors.load_xbm">
<big><b>pygame.cursors.load_xbm</big></b><br><ul>
  <i>load cursor data from an xbm file</i><br>
  <tt>pygame.cursors.load_xbm(cursorfile, maskfile=None): return cursor_args</tt><br>
<p>This loads cursors for a simple subset of <tt>XBM</tt> files. <tt>XBM</tt> files are traditionally used to store cursors on unix systems, they are an ascii format used to represent simple images. </p>
<p>Sometimes the black and white color values will be split into two separate <tt>XBM</tt> files. You can pass a second maskfile argument to load the two images into a single cursor. </p>
<p>The cursorfile and maskfile arguments can either be filenames or filelike object with the readlines method. </p>
<p>The return value cursor_args can be passed directly to the <tt><a href="mouse.html#pygame.mouse.set_cursor">pygame.mouse.set_cursor</a> - <font size=-1>set the image for the system mouse cursor</font></tt> function. </p>
<!--COMMENTS:pygame.cursors.load_xbm--> &nbsp;<br> 
<br></ul>
<br></ul>

</body></html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.