import tkinter as tk
from tkinter import ttk
import random as ran
with open("russian.txt", mode="w", encoding="CP1251") as file:
index=0 #index+5
spisok=["книга","чайка","дамба","папка","актёр","бобёр","взлёт","егерь","бомба","обчёт"]
answer=ran.choice(spisok)
def enter(*a,):
global index
word=entry_var.get()
if word==answer:
entry.config(text="Победа!")
entry.config(state="disabled")
print(word)
for i in range(30-index):
buttons[i+index].config(text='')
for t in range(0,len(word)):
buttons[t+index].config(text=word[t])
if len(word)==5:
entry.delete(0,tk.END)
for t in range(0,len(word)):
if word[t]==answer[t]:
buttons[index+t].config(bg="#ADFF2F")
elif word[t] in answer:
buttons[index+t].config(bg="#FF4500")
index+=5
else:
pass
if index==30:
entry.delete(0,tk.END)
entry.config(state="disabled")
entry.config(text="Вы проиграли")
print(index)
root = tk.Tk()
root.title("Wordle,but cheap")
root.geometry("200x300")
entry_var = tk.StringVar(root)
entry_var.trace("w", enter)
buttons=list()
entry = tk.Entry(root, width=25,textvariable=entry_var)
entry.grid(row=7, column=0, columnspan=70, padx=10, pady=0)
for i in range(0,30):
buttons.append(tk.Button(root, width = 3))
buttons[i].grid(row=i//5, column=i%5, padx=2, pady=5, rowspan=1)
root.mainloop()
Пожалуйста,ответьте сегодня