示例#1
0
def show_popup(task, textPosition):
    Log("Open Pop up input screen")
    background = SCREEN.copy()
    input = InputBox((360,268), BUFFER, color=[(179,179,179),(0,186,220),(179,179,179)],font_color=FONT_COLOR_POPUP, max_size=280, enable_rows = False)
    input.makeFocus()
    text = pygame.font.Font( FONT, FONT_SIZE ).render(task , True, (0,0,0) )
    running = True
    while running:
        mouseX, mouseY = pygame.mouse.get_pos()
        CLEAR(BUFFER)
        SCREEN.blit(background,(0,0))
        SCREEN.blit(PIC_POPUP,(0,0))
        SCREEN.blit(text,textPosition)
        SCREEN.blit(PIC_OK_BTN_UP, (393, 300))
        SCREEN.blit(PIC_CANCEL_BTN_UP, (520, 300))  
        
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                if show_security():
                    sys.exit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    running = False
            #Left mouseclick on OK button
            if event.type == pygame.MOUSEBUTTONDOWN and mouse_in_area(mouseX, mouseY, 393, 300, 87, 28) and  event.button == 1: 
                SCREEN.blit(PIC_OK_BTN_DOWN, (393, 300))            
            if event.type == pygame.MOUSEBUTTONUP and mouse_in_area(mouseX, mouseY, 393, 300, 87, 28) and  event.button == 1:
                running = False
            #Left mouseclick on CANCEL button
            if event.type == pygame.MOUSEBUTTONDOWN and mouse_in_area(mouseX, mouseY, 520, 300, 87, 28) and  event.button == 1: 
                SCREEN.blit(PIC_CANCEL_BTN_DOWN, (520, 300)) 
            if event.type == pygame.MOUSEBUTTONUP and mouse_in_area(mouseX, mouseY, 520, 300, 87, 28) and  event.button == 1:
                return None
            input.handleEvent(event)
            
        input.update(SCREEN)
        pygame.display.update()
    return input.getString()