【发布时间】:2022-08-19 10:47:28
【问题描述】:
我正处于创建记忆游戏的早期阶段。 我想要的是能够知道按下了哪个按钮,但我不知道该怎么做。例如,单击按钮后,文本会更改为其他内容。
from tkinter import *
import random
root = Tk()
root.title(\"Memory Game\")
buttons=[]#Stores the buttons
counter=0
x=0
y=0
for l in range(0,6):#Creates a grid of 36 working buttons and stores them in \"buttons\"
x=0
y+=1
for i in range(0,6):
buttons.append(Button(root,text=\"???\"))
buttons[counter].grid(column = x, row = y)
counter+=1
x+=1