import pygame
import sys
pygame.init()
screen = pygame.display.set_mode((400, 300))
pygame.display.set_caption("Text Input Example")
input_rect = pygame.Rect(100, 100, 200, 30)
pygame.key.start_text_input()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
print(event)
pygame.key.set_text_input_rect(input_rect)
screen.fill((255, 255, 255))
pygame.draw.rect(screen, (0, 0, 0), input_rect, 2)
pygame.display.flip()
import sys
pygame.init()
screen = pygame.display.set_mode((400, 300))
pygame.display.set_caption("Text Input Example")
input_rect = pygame.Rect(100, 100, 200, 30)
pygame.key.start_text_input()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
print(event)
pygame.key.set_text_input_rect(input_rect)
screen.fill((255, 255, 255))
pygame.draw.rect(screen, (0, 0, 0), input_rect, 2)
pygame.display.flip()