hello,
I want to mouse click a specific item.
When you click Activé which is button_A this line appear: img = font.render("Veuillez entrer votre code pour armer le systeme d'alarme!", True, BLANC)
Edit:
i am now able to click at activé but text of button A appear over B
Thank you
I want to mouse click a specific item.
When you click Activé which is button_A this line appear: img = font.render("Veuillez entrer votre code pour armer le systeme d'alarme!", True, BLANC)
Edit:
i am now able to click at activé but text of button A appear over B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# -*- coding: utf-8 -*- import pygame from pygame. locals import * import sys pygame.init() display = pygame.display.set_mode(( 300 , 300 )) FPS_CLOCK = pygame.time.Clock() #pygame.init() BLEU = ( 0 , 0 , 255 ) BLANC = ( 255 , 255 , 255 ) ROUGE = ( 255 , 0 , 0 ) GREEN = ( 0 , 255 , 0 ) BLACK = ( 0 , 0 , 0 ) GRIS = ( 200 , 200 , 200 ) BLANC = ( 255 , 255 , 255 ) NOIR = ( 0 , 0 , 0 ) screen = pygame.display.set_mode([ 700 , 500 ]) # Charger un police de caract�re sysfont = pygame.font.get_default_font() font = pygame.font.SysFont( None , 48 ) def bouton_A(screen, pos, texte): rayon = 55 pygame.draw.circle(screen, GREEN, pos, rayon) txtBtn = font.render(texte, True , NOIR) rectBtn = txtBtn.get_rect() rectBtn.center = (pos) screen.blit(txtBtn, rectBtn) def bouton_D(screen, pos, texte): rayon = 55 pygame.draw.circle(screen, ROUGE, pos, rayon) txtBtn = font.render(texte, True , NOIR) rectBtn = txtBtn.get_rect() rectBtn.center = (pos) screen.blit(txtBtn, rectBtn) def bouton_nb(screen, pos, texte): rayon = 25 pygame.draw.circle(screen, GRIS, pos, rayon) txtBtn = font.render(texte, True , NOIR) rectBtn = txtBtn.get_rect() rectBtn.center = (pos) screen.blit(txtBtn, rectBtn) sysfont = pygame.font.get_default_font() font = pygame.font.SysFont( None , 36 ) running = True while running: for event in pygame.event.get(): if event. type = = pygame.QUIT: running = False if event. type = = pygame.MOUSEBUTTONDOWN: x , y = pygame.mouse.get_pos() print (x,y) if x < 185 and y < 285 : img = font.render( "Veuillez entrer votre code pour armer le systeme d'alarme!" , True , BLANC) screen.blit(img, ( 20 , 100 )) if x < 538 and y < 292 : img = font.render( "Entrez votre code pour d�sarmer le systeme d'alarme!" , True , BLANC) screen.blit(img, ( 20 , 100 )) #screen.fill(BLANC) bouton_A(screen, ( 150 , 250 ), "Activ�" ) bouton_D(screen, ( 500 , 250 ), "D�sactiv�" ) bouton_nb(screen, ( 265 , 200 ), "1" ) bouton_nb(screen, ( 320 , 200 ), "2" ) bouton_nb(screen, ( 375 , 200 ), "3" ) bouton_nb(screen, ( 265 , 255 ), "4" ) bouton_nb(screen, ( 320 , 255 ), "5" ) bouton_nb(screen, ( 375 , 255 ), "6" ) bouton_nb(screen, ( 265 , 310 ), "7" ) bouton_nb(screen, ( 320 , 310 ), "8" ) bouton_nb(screen, ( 375 , 310 ), "9" ) #pygame.draw.circle(screen, GRIS, (260, 250), 25) pygame.display.flip() img = font.render( "Bienvenue" , True , ROUGE) screen.blit(img, ( 20 , 20 )) pygame.display.flip() pygame.display.update() FPS_CLOCK.tick( 30 ) pygame.quit() |