| | |
"replay" button for a GUI
![]() |
•
•
Join Date: Dec 2007
Posts: 5
Reputation:
Solved Threads: 0
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:
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.
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:
Python Syntax (Toggle Plain Text)
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.
![]() |
Other Threads in the Python Forum
- Previous Thread: Need help with a class problem.
- Next Thread: How to pass the parameters to a script?
| Thread Tools | Search this Thread |
address alarm anydbm app beginner cipher conversion coordinates curves cx-freeze data development dictionary directory dynamic examples excel feet file float format function generator getvalue gui halp handling homework images import input ip itunes java keycontrol line linux list lists loan loop maintain maze millimeter mouse mysqldb number numbers output parsing path port prime programming projects py2exe pygame pyglet pymailer python queue random recursion recursive screensaverloopinactive script scrolledtext searchingfile shebang slicenotation split ssh string strings table terminal text thread threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 variable variables ventrilo verify vigenere web webservice wx.wizard wxpython xlwt





