Мне нужна помощь в этом проекте python tkinter? (связано с отображением и обновлением текста этикетки)

#python #tkinter

Вопрос:

Я создал эту игру на python tkinter Главная страница игры

Страница оценки

Поэтому всякий раз, когда я выбирал какой-либо вариант, нажимая на любую кнопку на главной странице, данная игровая функция выполняется, и эта функция в основном обновляет значение всех меток (сыгранные игры, игры, которые вы выиграли, игры компьютер выиграл) теперь я хотел, чтобы одна игра содержала 5 раундов, поэтому я написал инструкцию if в функции, чтобы, как только мои сыгранные игры станут равными 5, она уничтожила все виджеты и отобразила страницу результатов. проблема в том, что всякий раз, когда я нажимаю кнопку в 5-й раз, она просто уничтожает главную страницу и показывает страницу результатов, но я хочу, чтобы она сначала обновила и отобразила тексты меток и подождала 10 секунд, а затем уничтожила виджеты и отобразила страницу результатов. проблема в том, что она обновляет тексты меток и ждет 10 секунд (я использовал после, чтобы подождать 10 секунд) но он не отображает обновленные тексты меток, поэтому я хочу знать, как я могу отобразить текст метки сразу после обновления. вот моя функция, которая вызывается при нажатии кнопки:-

 def game(player):  global win  global loss  global tie  global gamesPlayed  global winPercent   #asking user to confirm its choice  is_ok = messagebox.askyesno(title="Confirm Choice", message=f"You chose {player} n Press yes to confirm your choice:")  if not is_ok:  return   # getting the computers choice  cpu = ['Rock', 'Paper', 'Scissors', 'Lizard', 'Spock']  cpu = random.choice(cpu)   # see who won by comparing picks  if player == cpu:  result = 'Tied'  elif (player == 'Rock' and cpu == 'Paper') or (player == 'Paper' and cpu == 'Scissors') or (player == 'Scissors' and cpu == 'Rock') or (player == 'Rock' and cpu == 'Spock') or (player == 'Paper' and cpu == 'Lizard') or (player == 'Scissors' and cpu == 'Spock') or (player == 'Lizard' and cpu == 'Rock') or (player == 'Lizard' and cpu == 'Scissors') or (player == 'Spock' and cpu == 'Paper') or (player == 'Spock' and cpu == 'Lizard'):  result = 'Lost'  else:  result = 'Won'   # increment ties, losses and games played  if result == 'Tied':  tie  = 1  gamesPlayed  = 1  elif result == 'Lost':  loss  = 1  gamesPlayed  = 1  else:  win  = 1  gamesPlayed  = 1   # calculate the win percent  winPercent = int(win)/int(gamesPlayed)*100  won = str(round(winPercent, 1))   # added the funny sayings to go with the choices  sayings = {  1: "Rock crushes Lizard...",  2: "Scissors cuts Paper...",  3: "Paper covers Rock...",  4: "Lizard Poisons Spock...",  5: "Spock smashes Scissors...",  6: "Scissors decapitates Lizard...",  7: "Lizard eats Paper...",  8: "Paper disproves Spock...",  9: "Spock vaporizes Rock...",  10: "Rock crushes Scissors...",  11: "Tie Game!"}   if (player == 'Rock' and cpu == 'Lizard') or (cpu == 'Rock' and player == 'Lizard'):  display = sayings[1]  elif (player == 'Scissors' and cpu == 'Paper') or (cpu == 'Scissors' and player == 'Paper'):  display = sayings[2]  elif (player == 'Paper' and cpu == 'Rock') or (cpu == 'Paper' and player == 'Rock'):  display = sayings[3]  elif (player == 'Lizard' and cpu == 'Spock') or (cpu == 'Lizard' and player == 'Spock'):  display = sayings[4]  elif (player == 'Spock' and cpu == 'Scissors') or (cpu == 'Spock' and player == 'Scissors'):  display = sayings[5]  elif (player == 'Scissors' and cpu == 'Lizard') or (cpu == 'Scissors' and player == 'Lizard'):  display = sayings[6]  elif (player == 'Lizard' and cpu == 'Paper') or (cpu == 'Lizard' and player == 'Paper'):  display = sayings[7]  elif (player == 'Paper' and cpu == 'Spock') or (cpu == 'Paper' and player == 'Spock'):  display = sayings[8]  elif (player == 'Spock' and cpu == 'Rock') or (cpu == 'Spock' and player == 'Rock'):  display = sayings[9]  elif (player == 'Rock' and cpu == 'Scissors') or (cpu == 'Rock' and player == 'Scissors'):  display = sayings[10]  else:  display = sayings[11]   # updated to display the last rounds results and scores  lbl_result['text'] = f'You {result}! You played {player}, the computer played {cpu}.'  lbl_sayings['text'] = f'{display}'  lbl_score['text'] = f'ScorenGame You Won: {win}nGames Computer Won: {loss}nTies: {tie}'  lbl_gamesPlayed['text'] = f'You have played {gamesPlayed} games.'  lbl_winPercent['text'] = f'Win Percent: {won}'   '%'   if gamesPlayed == 5:  window.after(1000, game_completed())  

here at the updated to display the last rounds results and scores part I want my program to display updated text immediately before the if statements execution