如何从菜单栏

时间:2015-06-18 23:45:33

标签: python python-2.7 tkinter exit menubar

我已经制作了一些代码来玩游戏,我添加了这个,所以有一个选项可以从菜单栏关闭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()

0 个答案:

没有答案