External Exam Download Resources Web Applications Games Recycle Bin

Show an image from a file

input from console.py

import pygame
pygame.init()
screen = pygame.display.set_mode((400, 300))
done = False
console_input = ""

while not done:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      done = True

    if event.type == pygame.KEYDOWN: #pressed once
      if event.key == pygame.K_SPACE: #space key   
        console_input = input("enter a string: ")

    if event.type == pygame.MOUSEBUTTONDOWN: #single click
      print("last string entered:", console_input)
    
  pygame.display.flip()
pygame.quit()