When I try to run this pygame code it instantly closes??
The window doesn't close instantly when I stop drawing text, so I know I must've done something wrong.
import pygame
background_colour = (255, 255, 255)
(width, height) = (1920, 1080)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('fat')
screen.fill(background_colour)
font = pygame.font.Font(None, 32)
color = pygame.Color('dodgerblue2')
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
text = ""
while running:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
vanishingtext += event.unicode
text += event.unicode
elif event.type == pygame.K_BACKSPACE:
text = text[:-1]
elif event.type == pygame.K_RETURN:
interpret(text)
text = ""
else:
pass
txt_surface = font.render(text, True, color)
screen.blit(txt_surface, (50, 100))
i expect for a screen to appear that allows me to type and backspace, if i press enter the text should completely disappear and a function should run that will interpret the string. i haven't defined interpet as a function yet, but i'm doing it after i've figured out if i can even make it work on a screen.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)