why cannot the "for" loop to get the value from the list?

Viewed 48

when I use "rb = random.choice(myList) and bFont", it's function. then I use "for i in range(len(myList)) and bFont" and click, it cannot loop, just display a fix list value, why?

import pygame
import random
import re
pygame.mixer.init()
pygame.init()
size = (1280, 580)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("1")
bg = pygame.image.load("b")
white = (0, 0, 0)
black = (230, 0, 100)
light_grey = (224, 224, 224)
dark_grey = (200, 200, 200)
text = pygame.font.SysFont("Agency FB", 20)
myList = ["a5一个5ˈei", "am5是5æm", "are5是5a:r"]
font = pygame.font.Font('./simhei.ttf', 25)
button_text = font.render("aaaaa", True, black)
button_rect = pygame.Rect(70, 350, 200, 200)
bFont = None
var = True
while var:
    mouse = pygame.mouse.get_pos()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            var = False
        if event.type == pygame.MOUSEBUTTONDOWN:
            if button_rect.collidepoint(event.pos):


                for i in range(len(myList)):
                #rb = random.choice(myList)
                    bFont = font.render(myList[i], True, white)
                    bFont1 = font.render(myList[i], True, white)
                #bFont = font.render(rb, True, white)
                #bFont1 = font.render(rb, True, white)

                
    screen.blit(bg, (0, 0))
    if button_rect.collidepoint(mouse):
        pygame.draw.rect(screen, dark_grey, (70, 350, 200, 200), 0)
    else:
        pygame.draw.rect(screen, light_grey, (70, 350, 200, 200), 0)
    screen.blit(button_text, (90, 450))
    if bFont:
        screen.blit(bFont, (70, 100))
        screen.blit(bFont1, (70, 220))
    pygame.display.update()

\help me \help

0 Answers
Related