External Exam Download Resources Web Applications Games Recycle Bin

Mouse Click

mouse click position.py

import pygame
pygame.init()
screen = pygame.display.set_mode((400, 300))
done = False
while not done:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      done = True

    if event.type == pygame.MOUSEBUTTONDOWN: #single click
      position = pygame.mouse.get_pos()
      print(position)
      
  pygame.display.flip()
pygame.quit()