我已经制作了一些代码来玩游戏,我添加了这个,所以有一个选项可以从菜单栏关闭Tkinter
窗口,但点击时没有任何反应。我是否需要使用lambda
或返回值而不是函数引用?
menubar.add_cascade(label="Exit", underline=0, command = self.close_Game())
def close_Game(self):
if self.players_done >= self.num_Players:
self.in_close_Game == 1
#print "players done" + str(self.players_done)
if self.displayed_Game_Over == 0:
#print("in close game")
winsound.PlaySound("GameOver.wav", winsound.SND_ASYNC)
print("GAME OVER!!! WINNER IS: " + self.current_leader_name +
self.newline + " WITH SCORE: " + str(self.current_leader_points))
self.newButton.config(text = "Press Again to Close", command = self.close_Now)
self.displayed_Game_Over = 1
else:
# print "not over"
return
def close_Now(self):
self.window2.destroy()
sys.exit()