"replay" button for a GUI

Reply

Join Date: Dec 2007
Posts: 5
Reputation: Tetch is an unknown quantity at this point 
Solved Threads: 0
Tetch Tetch is offline Offline
Newbie Poster

"replay" button for a GUI

 
0
  #1
Dec 5th, 2007
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:
  1. def endGame(root):
  2. def play():
  3. curr = CurrentFunds()
  4. root.destroy()
  5.  
  6. def stop():
  7. root.destroy()
  8.  
  9. endLabel = Label(root, text = "I'm sorry, you have run out of money. \n" \
  10. "Better luck next time!")
  11. endLabel.pack()
  12.  
  13. closeButton = Button(root, text = 'Close')
  14. closeButton.config(command = stop)
  15. closeButton.pack(side=BOTTOM)
  16.  
  17. retryButton = Button(root, text = 'Play Again?')
  18. retryButton.config(command = play)
  19. 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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC