943,778 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 6788
  • Python RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jan 4th, 2009
0

Re: pygame window not working

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
Reputation Points: 462
Solved Threads: 392
Senior Poster
evstevemd is offline Offline
3,681 posts
since Jun 2007
Jan 5th, 2009
0

Re: pygame window not werking

I don't remember the full syntax, nor if it is actually what you are looking for but try
Python Syntax (Toggle Plain Text)
  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".

Python Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Nuez_Jr is offline Offline
18 posts
since Oct 2004
Jan 5th, 2009
0

Re: pygame window not werking

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Nuez_Jr is offline Offline
18 posts
since Oct 2004
Jan 5th, 2009
0

Re: pygame window not werking

Try this from the interpreter (after creating a window)
Python Syntax (Toggle Plain Text)
  1. while True:
  2. print pygame.event.wait()
to see all the events a window typically recieves.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Nuez_Jr is offline Offline
18 posts
since Oct 2004
Jan 1st, 2010
0

it works

Quote originally posted by KABOOM! ...
i have discovered that if you add pygame.display.flip()...
Python Syntax (Toggle Plain Text)
  1. import sys, pygame
  2. from pygame.locals import *
  3.  
  4. pygame.init()
  5. screen = pygame.display.set_mode((640,480))
  6. pygame.display.flip()



the display will show the screen black like its supposed to , !but it will still will say not responding.if you add a while loop to the end it will work 100%%

Python Syntax (Toggle Plain Text)
  1.  
  2. import pygame,sys
  3. from pygame.locals import*
  4.  
  5. screen = pygame.display.set_mode((640,480))
  6. pygame.display.flip()
  7.  
  8. while 1:
  9. for event in pygame.event.get():
  10. if event.type==QUIT:
  11. pygame.quit()
  12. sys.exit()
Last edited by KABOOM!; Jan 1st, 2010 at 4:38 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KABOOM! is offline Offline
1 posts
since Jan 2010
Jan 3rd, 2010
0
Re: pygame window not werking
A very nice introduction to pygame programming ...
http://inventwithpython.com/chapter16.html
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: tabarray input error: incomplete records
Next Thread in Python Forum Timeline: Annoying Error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC