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
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
# -*- 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()
Thank you
