Help save net neutrality! Learn more.
Close

different cursors

2001-05-19
2001-05-19
  • Bob Ippolito

    Bob Ippolito - 2001-05-19

    Just so happens that the day I was about to start writing my own pygame ui library this comes out.. Anyways, I like hand cursors over buttons as opposed to rollovers, so I threw together some quick cursors to use with pyui..

    Note: this is very sloppy (but my changes are clean), I'm developing in win32 and don't have the original files for a diff or any CVS utils intalled.  Unfortunately I'll probably be making a lot more changes to my copy of pyui this weekend in the same manner ;)

    Anyhow.. to use them, put cursors.py in your pyui folder and make these changes:

    in core.py after:
    from theme import theme
    add the line:
    import cursors
    and change the line that sets the cursor to the pygame default cursor to:
    pygame.mouse.set_cursor(*cursors.arrow)

    .. also, if you want the hand icon on rollover, do the following to widgets.py:

    after import theme, insert this line:
    import cursors

    in the onMouseMotion method of the Button class, add this right after if not self.hit(event.pos):
    if self.status == Button.ROLLOVER:
      pygame.mouse.set_cursor(*cursors.arrow)

    and this right after if self.status == Button.IDLE:
    pygame.mouse.set_cursor(*cursors_hand)

    ##################
    ### cursors.py ###
    ##################

    ## cursors similar to windows for use with pygame

    """Set of cursors familiar to windows users
    """
    import pygame.cursors
    arrow_strings = ( #sized 24x24
      "X                       ",
      "XX                      ",
      "X.X                     ",
      "X..X                    ",
      "X...X                   ",
      "X....X                  ",
      "X.....X                 ",
      "X......X                ",
      "X.......X               ",
      "X........X              ",
      "X.........X             ",
      "X..........X            ",
      "X......XXXXXX           ",
      "X...X..X                ",
      "X..XX..X                ",
      "X.X  X..X               ",
      "XX   X..X               ",
      "X     X..X              ",
      "      X..X              ",
      "       X..X             ",
      "       X..X             ",
      "        XX              ",
      "                        ",
      "                        ",
    )
    hand_strings = ( #sized 24x24
      "     XX                 ",
      "    X..X                ",
      "    X..X                ",
      "    X..X                ",
      "    X..X                ",
      "    X..XXX              ",
      "    X..X..XXX           ",
      "    X..X..X..XX         ",
      "    X..X..X..X.X        ",
      "XXX X..X..X..X..X       ",
      "X..XX........X..X       ",
      "X...X...........X       ",
      " X..X...........X       ",
      "  X.X...........X       ",
      "  X.............X       ",
      "   X............X       ",
      "   X...........X        ",
      "    X..........X        ",
      "    X..........X        ",
      "     X........X         ",
      "     X........X         ",
      "     XXXXXXXXXX         ",
      "                        ",
      "                        ",
    )
    arrow=((24,24),(0,0))+pygame.cursors.compile(arrow_strings,".","X")
    hand=((24,24),(5,0))+pygame.cursors.compile(hand_strings,".","X")

     
    • Bob Ippolito

      Bob Ippolito - 2001-05-19

      Doh!  HTML screwed up the spaces on the cursor strings!

      If anyone would like to use them, feel free to fix them yourself or email me at bob@threeoh.com and I'll send off my copy

       
    • Sean Riley

      Sean Riley - 2001-05-19

      the first contribution of code from a third party!
      this is just like a real open source project!

       

Log in to post a comment.