|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pygame help
I made a physics sim and I'm trying to add simple graphics. I tried to fill the window with white, but the window stays black until I move another window over it then it turns to white. And when I try to exit the window An error occurs it says:
Traceback (most recent call last): File "filename", line 82, in -toplevel- if event.type == pygame.QUIT: sys.exit() SystemExit If you can help thanks. |
|
#2
|
|||
|
|||
|
It is virtually impossible to diagnose problems with your code if you don't post it up.
The PyGame problem sounds like you need to refresh/redraw the window after making it white. I do not know the pygame API, but there is probably a function or method to do this that needs to be called. As for the other problem, I see from the traceback you are calling sys.exit, which raises a SystemExit exception to exit the program. It is doing exactly what you told it. What did you expect? Dave - The Developers' Coach |
|
#3
|
|||
|
|||
|
I'm redrawing the backround so i know its not that. And i expected it to close the window when i try to quit
|
|
#4
|
|||
|
|||
|
Do you call pygame.display.flip() after filling the window with white? You will not see any changes until you call that, since all the graphics are sent to the hidden buffer.
sys.exit() should exit the system. I have read the Pygame tutorial and I see that their example uses it too, but it is bad programming practice - sys.exit is really for abnormal program termination where you want to return an error code to the OS. It would be better to break out of the loop and let the program flow run to the end. I don't know it that will help or not, since you still have not posted up any source code. BTW, I think calling sys.exit from a thread will kill the thread but not kill the application, so don't do that. It can also be trapped by a try: except: clause and ignored, so don't do that either. Dave - The Developers' Coach |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Pygame help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|