0

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()
TigerhawkT3
  • 48,464
  • 6
  • 60
  • 97
Nick Folz
  • 93
  • 1
  • 7
  • 1
    You are using `close_Game` instead of `close_Now`. Also, you should pass the method itself, not the result of it, so you shouldn't use the () on it. It should look like: `menubar.add_cascade(label="Exit", underline=0, command=self.close_Now)` – user3557327 Jun 18 '15 at 23:49
  • thank you...I was looking through my whole code and somehow missed this thanks! – Nick Folz Jun 19 '15 at 00:05

0 Answers0