Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 16th, 2004, 10:37 PM
The_SkunkMan The_SkunkMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 7 The_SkunkMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old July 17th, 2004, 04:16 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,226 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 35 m 17 sec
Reputation Power: 263
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

Reply With Quote
  #3  
Old July 17th, 2004, 10:46 PM
The_SkunkMan The_SkunkMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 7 The_SkunkMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm redrawing the backround so i know its not that. And i expected it to close the window when i try to quit

Reply With Quote
  #4  
Old July 18th, 2004, 05:03 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,226 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 35 m 17 sec
Reputation Power: 263
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Pygame help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT