Я пытаюсь сделать небольшую игру, которая показывает вам окно с 8 кнопками, и вы выбираете одну, чтобы выиграть.Следующие 7 кнопок должны быть пропущены.Окно выскакивает, но кнопок нет.Есть идеи, что не так с кодом?
from tkinter import *
import random
t = Tk()
t.title("Select button")
t.geometry("300x350")
def insert_buttons():
count_buttons=8
global buttons
buttons = []
good = random.randint (0,count_buttons-1)
for i in range (count_buttons):
if i == good:
buttons.append(Button(t, text = "Select", command=hit))
else:
buttons.append(Button(t, text = "Select", command=miss))
for i in buttons:
i.pack (fill=BOTH, expand=YES)
def hit():
for i in buttons:
i.destroy()
global etykiet
etykiet = label(t, text = "BRAWO! It's a hit!")
etykiet.pack(fill=BOTH, expand=YES)
t.after(5000,restart)
def miss():
for i in buttons:
i.destroy()
global etykiet
etykieta = label(t, text - "Try again")
etykieta.pack(fill=BOTH, expand=YES)
t.after(5000, restart)
def restart():
etyket.destroy()
inserty_buttons()