Ggfg
Ggg
Hyvh
from tkinter import * # графическая библиотека
from random import shuffle # перемешать список suffle(A)
column = 8 # столбцы
row = 8 # строки
btn = [] # список кнопок
playground = [0, 1] * (column * row //2)
shuffle(playground)
def play(n): # функция обработчик нажатия на кнопку
playground[n] = not playground[n]
for i in range (n%column, column*row, column):
playground[i] = not playground[i]
btn[i].config(image = img[playground[i]])
for i in range (n-n%column, n-n%column+column):
playground[i] = not playground[i]
btn[i].config(image = img[playground[i]])
tk = Tk()
tk.geometry('750x750')
img =[PhotoImage(file='emerald.png'),PhotoImage(file='bronze.png')]
for i in range(row):
f = Frame()
f.pack(expand=YES, fill=BOTH)
for j in range(column):
n = i * column + j
btn += [Button(f, image=img[playground[n]])]
btn[-1].pack(expand=YES, fill=BOTH, side=LEFT)
btn[-1].config(command=lambda n=n:play(n))
mainloop()
Ggb