Python tkinter破坏不工作

Python tkinter破坏不工作,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,因此,我正在用python和tkinter编写一个游戏,游戏结束时我需要一个弹出窗口,但当我单击“再次播放”按钮时,它不会破坏弹出窗口。弹出窗口上的消息也会用花括号显示,即“{游戏结束,玩家}红色获胜 以下是弹出窗口代码: def gameOverPopup(winOrTie): if winOrTie==True: lText=("Game over, player",player,"wins!") else: lText=("Game over, board full

因此,我正在用python和tkinter编写一个游戏,游戏结束时我需要一个弹出窗口,但当我单击“再次播放”按钮时,它不会破坏弹出窗口。弹出窗口上的消息也会用花括号显示,即“{游戏结束,玩家}红色获胜

以下是弹出窗口代码:

def gameOverPopup(winOrTie):
    if winOrTie==True:
    lText=("Game over, player",player,"wins!")
else:
    lText=("Game over, board full!")
popup=tk.Toplevel()
winLabel=tk.Label(popup,text=lText)
winLabel.grid(column=1,row=1,padx=50,pady=25)
againButton=tk.Button(popup,text="Play again",command=resetGame(popup))
againButton.grid(column=1,row=2,padx=50,pady=25)
endButton=tk.Button(popup,text="Quit",command=window.destroy)
endButton.grid(column=1,row=3,padx=50,pady=25)

def resetGame(popup):
    popup.destroy

您需要使用括号调用
destroy

popup.destroy()
要正确显示消息,它需要是字符串而不是元组:

lText="Game over, player %s wins!" %player

您需要使用
popup.destroy()调用destroy()
大括号是因为您要将
lText
设置为元组。删除paren并使其成为字符串。