pygame window not werking

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2007
Posts: 1,492
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 128
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: pygame window not working

 
0
  #11
Jan 4th, 2009
Originally Posted by ohblahitsme View Post
Are you guys putting the code into the interactive python interpreter or are you creating a separate .py file. When I started my first pygame project, I tried putting it in the interpreter and got an Not Responding window. Of course I just started python and pygame so what do I know .
Why not try to run it from IDEs like Drpython, or Wing 101 and tell us the progress
Last edited by evstevemd; Jan 4th, 2009 at 2:24 pm. Reason: clear up confusion
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
---- Python, C++ PHP and Java ----
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 18
Reputation: Nuez_Jr is an unknown quantity at this point 
Solved Threads: 1
Nuez_Jr's Avatar
Nuez_Jr Nuez_Jr is offline Offline
Newbie Poster

Re: pygame window not werking

 
0
  #12
Jan 5th, 2009
Originally Posted by ohblahitsme View Post
I don't remember the full syntax, nor if it is actually what you are looking for but try
  1. pygame.display.flip()
If I've understood correctly, flip() is specifically for double-buffered surfaces ... or more specifically, for changing buffers on surfaces for which you're taking advantage of SDL double buffering in the first place.

I've since found another tutorial that enlightened me re: the Not Responding window. It turns out the reason the window is 'not responding' is because our code is literally not responding to its event queue. Mouse clicks, mouse moves, key presses, and in fact lots of other random crud too, all pile up in the Windows Message Queue, and when Windows detects that a program isn't processing its messages (and thereby removing them from the queue - kind of like not reading your mail and letting it pile up in the mailbox), then Windows marks that window "Not Responding".

  1. pygame.event.get()
  2. # returns a list of events. I haven't read ahead enough to know how to
  3. # deal with them individually, i.e. look for typed letters
  4. # (as opposed to scanning the keyboard contstantly, hoping you don't miss one...)
  5. # ... but I have determined that calling this function:
  6. # - clears the message queue
  7. # - makes the game window's 'Not Responding' tag go away
  8. # - allows all the drawn changes to show up
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 18
Reputation: Nuez_Jr is an unknown quantity at this point 
Solved Threads: 1
Nuez_Jr's Avatar
Nuez_Jr Nuez_Jr is offline Offline
Newbie Poster

Re: pygame window not werking

 
0
  #13
Jan 5th, 2009
Originally Posted by ohblahitsme View Post
Are you guys putting the code into the interactive python interpreter or are you creating a separate .py file. When I started my first pygame project, I tried putting it in the interpreter and got an Not Responding window. Of course I just started python and pygame so what do I know .
For a program run from a file, even if it doesn't do any event processing, the window's lifetime will be so short that it probably won't have a chance for any unprocessed events to pile up. So that way a program that is incorrect in that it does not check for events will still appear to work. I suspect that the reason I could see my circle drawn onscreen just before the window went away was that part of pygame.quit()'s job is to throw away any remaining events in the queue, and when that happens the drawing updates can go through as the last things to happen before the window dies.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 18
Reputation: Nuez_Jr is an unknown quantity at this point 
Solved Threads: 1
Nuez_Jr's Avatar
Nuez_Jr Nuez_Jr is offline Offline
Newbie Poster

Re: pygame window not werking

 
0
  #14
Jan 5th, 2009
Try this from the interpreter (after creating a window)
  1. while True:
  2. print pygame.event.wait()
to see all the events a window typically recieves.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum


Views: 4550 | Replies: 13
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC