我使用Tkinter来编写一个游戏,我需要一个按钮(按钮a)主要是关闭的,而不是当一个不同的按钮(按钮B)被按下时按钮a打开这里是我迄今为止尝试的
def click(): # defines the press of Button B
p1name = P1.get()
p2name = P2.get()
namethanks = 'thank you "' + p1name + ' " you are player 1 (X) \n and thank you "' + p2name +'" you are player 2 (O)'
namesubmission.insert(END, namethanks)
realgametime.configure(state=DISABLED,)
这就是代码定义按钮A
realgametime(window, text="play the game", width=13, command=play, bg=bgcolour, fg=fgcolour, state=DISABLED) .grid(row=4, column=1, sticky=W) # button A
那么这就是错误:
请帮忙
据我所知,你曾经
创建按钮,但未将其分配给任何变量
调用
realgametime.configure
时,是在类本身上调用方法,而不是在实例化的按钮上调用方法试着这样做:
相关问题 更多 >
编程相关推荐