无法弄清楚 Pygame 应用程序有什么问题

Can't figure out what's wrong in Pygame app

我正在写这次反应测试。它应该显示文本,等待击键并开始试验,将结果测量附加到文件中。但它只显示文本并冻结。该死。如果您能帮我指出问题,我将不胜感激

import pygame
import random 
import time

pygame.init()

red = (255, 0, 0)
light_sea_green = (32, 178, 172) 
white = (255, 255, 255)
black = (0, 0, 0)

height, width = pygame.display.Info().current_w,pygame.display.Info().current_h

try:
    screen = pygame.display.set_mode((height, width), pygame.FULLSCREEN)
except pygame.error:
    screen = pygame.display.set_mode((780, 1360), pygame.FULLSCREEN)
    print("display err")

screen.fill(white)
pygame.display.flip()
pygame.display.set_caption("TRTest")

data = open("data.txt", "r+")
sid = len([l for l in data.readlines()]) + 1

while True:
    start = False
fnt = pygame.font.Font(None, 28)
txtrn = fnt.render("TR, press return", 0, (0, 0, 0))                
screen.blit(txtrn, (((height/2) - (txtrn.get_rect().width/2)), ((width/2) - (txtrn.get_rect().height)/2)))  
pygame.display.flip()

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

while start == True:
    for x in range(3): #3 Trials
        screen.fill((255, 255, 255))
        pygame.draw.line(screen, (0, 0, 0), (height/2, width/2 - 10), (height/2, width/2 + 10), 2)    
        pygame.draw.line(screen, (0, 0, 0), (height/2 - 10, width/2), (height/2 + 10, width/2), 2)    
        pygame.display.flip()    
        pygame.time.delay(random.randint(2000, 8000))
        pygame.draw.circle(screen, red, (height/2, width/2), 80)
        pygame.display.flip()
        t0 = time.clock()
        pygame.event.clear()
        running = True
        while running:
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    t1 = time.clock()
                    tr = (t1 - t0)
                    data.append(round(tr, 3))
                    running = False
                elif event.type == pygame.QUIT:
                    pygame.quit()

您需要 = 而不是代码中的 ==

if event.type == pygame.KEYDOWN:
     start == True # <--- need `=` instead of `==`
while True:
    start = False

这是一个无限循环。