[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Mouse



Hello again,
Currently I'm making a message window like this:

    if sys.platform == 'win32':
        os.environ['SDL_VIDEO_CENTERED'] = '1'
    surface = pygame.display.set_mode ((300,200), 16)
    options = pygame.image.load("Data/Options.png")
    check = pygame.image.load("Data/Check.png")
    Done = pygame.image.load("Data/Done.png")
    Done2 = pygame.image.load ("Data/Done2.png")
    pygame.mouse.set_pos(150, 100)
    while 1:
        pos = pygame.mouse.get_pos()
        surface.blit(options, (0,0))
        if (pos[0] >= 115 and pos[0] <= 194) and (pos[1] >= 168 and pos[1] <= 189):
            surface.blit(Done2, (115,168))
        else:
            surface.blit(Done, (115,168))
        pygame.display.flip()

Done is a button with "Done" on it, and Done2 is the same button but highlighted.  options is the background and is irrelevant.  In the loop, the idea is to draw the latter when the mouse crosses over it.  Otherwise, it draws Done.  The program however, when run, draws only Done and does not highlight (draws Done2) when moved over.