Tetch 0 Newbie Poster

Okay, I'm putting the finishing touches on a program I made that would simulate the game of Roulette at a casino, and I've run into a small problem.

Once the player runs out of money, I have a "game over" window that appears to notify them that they are now broke.

In this "Game Over" window, I wanted to:
a) Have a 'close' button, which would close both windows (the game over window AND the actual game interface)
b) Have a 'replay' button which would essentially reset the game, possibly by closing the original window and opening a new one altogether

I tried to implement this idea with this code:

def endGame(root):
        def play():
            curr = CurrentFunds()
            root.destroy()

        def stop():
            root.destroy()

        endLabel = Label(root, text = "I'm sorry, you have run out of money. \n" \
                         "Better luck next time!")
        endLabel.pack()
        
        closeButton = Button(root, text = 'Close')
        closeButton.config(command = stop)
        closeButton.pack(side=BOTTOM)

        retryButton = Button(root, text = 'Play Again?')
        retryButton.config(command = play)
        retryButton.pack(side=BOTTOM)

The problem is, I don't know how I would go about closing both windows, and also, if they clicked the replay button, I'm unsure of how to reopen the game.

The code above is located outside of the main function in my program, and if you want to take a look at what the program as a whole looks like, there's a link to another topic that I posted it in: http://www.daniweb.com/forums/thread99499.html

The code in that topic is 700 lines long though, so you might want to spare yourself the headache if you can. It is also unfinished, and I would advise against running it, as in the state it's in, it is an infinite loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.