How to exit a Tkinter window from a menubar

44 views Asked by At

I have made some code to play a game and I added this so there is an option to close the Tkinter window from a menubar but when clicked nothing happens. Do I need to use lambda or a return value instead of a function reference?

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

There are 0 answers