You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
847 B
Python
32 lines
847 B
Python
# Imports
|
|
import pygame_textinput
|
|
import pygame
|
|
# Set Up
|
|
pygame.init()
|
|
# Class
|
|
def textinput():
|
|
# Window
|
|
screen = pygame.display.set_mode((300, 50))
|
|
pygame.display.set_caption("Enter level number")
|
|
# Set Up
|
|
textinput = pygame_textinput.TextInput()
|
|
clock = pygame.time.Clock()
|
|
# Game Loop
|
|
run = True
|
|
while run:
|
|
# Background
|
|
screen.fill((225, 225, 225))
|
|
events = pygame.event.get()
|
|
# QUIT
|
|
for event in events:
|
|
if event.type == pygame.QUIT:
|
|
exit()
|
|
# Feed Events
|
|
if textinput.update(events):
|
|
run = False
|
|
return textinput.get_text()
|
|
# Output
|
|
screen.blit(textinput.get_surface(), (10, 10))
|
|
# Display
|
|
pygame.display.update()
|
|
clock.tick(30) |