pygame window not werking

Thread Solved

Join Date: Jan 2006
Posts: 5
Reputation: senateboy is an unknown quantity at this point 
Solved Threads: 0
senateboy senateboy is offline Offline
Newbie Poster

pygame window not werking

 
0
  #1
Jan 15th, 2006
im using the python command prompt to enter these commands and after the window is shown. it becomes "not responding" which makes all later commands to it do absolutly nothing, including simply trying to resize the window with the mouse. this is how the code starts out...

  1. import os, sys, pygame
  2. from pygame.locals import *
  3.  
  4. pygame.init()
  5. window = pygame.display.set_mode((420,280))
  6. #everything here after does nothing to the window
  7. pygame.display.set_caption("my window")
  8. #etc...


im using windows XP
any ideas?
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 6
Reputation: PKort is an unknown quantity at this point 
Solved Threads: 1
PKort PKort is offline Offline
Newbie Poster

Re: pygame window not werking

 
0
  #2
Jan 16th, 2006
Originally Posted by senateboy
im using the python command prompt to enter these commands and after the window is shown. it becomes "not responding" which makes all later commands to it do absolutly nothing, including simply trying to resize the window with the mouse. this is how the code starts out...

  1. import os, sys, pygame
  2. from pygame.locals import *
  3.  
  4. pygame.init()
  5. window = pygame.display.set_mode((420,280))
  6. #everything here after does nothing to the window
  7. pygame.display.set_caption("my window")
  8. #etc...

im using windows XP
any ideas?
Pygame and Idle don't work very well together ...
Try to use something like drPython or Boa as an editor.

Peter.
http://www.pkort.nl
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,956
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 917
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: pygame window not werking

 
0
  #3
Jan 17th, 2006
Did you put the event loop in? This is a code sample of a very basic pygame program ...
  1. import pygame
  2. from pygame.locals import *
  3.  
  4. yellow = (255,255,0) # RGB color tuple
  5.  
  6. # initialize screen
  7. pygame.init()
  8. screen = pygame.display.set_mode((350, 250))
  9. pygame.display.set_caption('Basic Pygame program')
  10.  
  11. # fill background
  12. background = pygame.Surface(screen.get_size())
  13. background = background.convert()
  14. background.fill(yellow)
  15.  
  16. # display some text
  17. font = pygame.font.Font(None, 36)
  18. text = font.render("Hello from Monty PyGame", 1, (10, 10, 10))
  19. textpos = text.get_rect()
  20. textpos.centerx = background.get_rect().centerx
  21. background.blit(text, textpos)
  22.  
  23. # blit everything to the screen
  24. screen.blit(background, (0, 0))
  25. pygame.display.flip()
  26.  
  27. # event loop
  28. while 1:
  29. for event in pygame.event.get():
  30. if event.type == QUIT:
  31. raise SystemExit
  32. screen.blit(background, (0, 0))
  33. pygame.display.flip()
Last edited by vegaseat; Aug 27th, 2007 at 7:58 pm. Reason: php-->python tag
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1
Reputation: jeff209 is an unknown quantity at this point 
Solved Threads: 1
jeff209 jeff209 is offline Offline
Newbie Poster

Re: pygame window not werking

 
0
  #4
Aug 26th, 2007
This Has been happening to me also
I want to learn how to program games and python was a good place to start, but every time i go to open a game window it opens as non responsive program and it makes me restart the python shell
I check my versions of pygame and python and they both match

Any help would be nice.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,514
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 168
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: pygame window not werking

 
0
  #5
Aug 27th, 2007
This would be a very basic pygame program, see if you can get that to work:
  1. # fooling around with pygame --> draw/fill some rectangles
  2.  
  3. import pygame as pg
  4.  
  5. # initiate pygame first
  6. pg.init()
  7.  
  8. #create a 400x300 window
  9. screen = pg.display.set_mode((400, 300))
  10. # give it a title
  11. pg.display.set_caption('Draw/fill rectangles using pygame')
  12.  
  13. # some color constants
  14. white = 0xFFFFFF
  15. red = 0xFF0000
  16. green = 0x00FF00
  17. blue = 0x0000FF
  18. yellow = 0xFFFF00
  19.  
  20. #draw/fill a 77x33 rectangle in position x=250, y=50 (NW corner)
  21. screen.fill(white, (250, 50, 77, 33))
  22.  
  23. # more rectangles, vary color, size, position ...
  24. screen.fill(red, (30, 20, 70, 120))
  25. screen.fill(red, (140, 70, 90, 80))
  26. screen.fill(green, (150, 80, 70, 60))
  27. screen.fill(yellow, (200, 170, 150, 60))
  28. screen.fill(blue, (70, 200, 100, 70))
  29.  
  30. # hey, nothing gets displayed until one updates the screen
  31. pg.display.update()
  32.  
  33. # create the event loop to get things going
  34. # and specify an exit action (clicking on the window x)
  35. while True:
  36. for event in pg.event.get():
  37. if event.type == pg.QUIT:
  38. raise SystemExit
drink her pretty
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
  #6
Jan 3rd, 2009
(Google turned up this thread for me...)

Same problem. I've tried it by typing right into Python, from the Windows shell (cmd.exe) and from a Cygwin bash shell, and got slightly different behavior in each case, but either way the PyGame window is unresponsive.

  1. import pygame
  2. a = pygame.display.set_mode((400, 300))
  3. # the surface window appears in both cases
  4. # it's grey and unavailable when I invoke python.exe (Windows version) from bash
  5. # the background is filled with black, but still unavailable when I invoke python.exe from CMD
  6. pygame.draw.circle(a, (255, 255, 255), (100, 100), 20)
  7. pygame.display.flip()
  8. # nothing happens
  9. pygame.quit()
  10. # surface window eventually disappears
  11. # under CMD -only-, the white circle appears briefly just before the window closes
  12. # under bash, no change is observed before closing

python.exe remains responsive throughout, but the graphics window is always in a 'busy' state, with the "busy" mouse cursor. It acquires the "(Not Responding)" caption after mouse or keyboard input.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 2
Reputation: ohblahitsme is an unknown quantity at this point 
Solved Threads: 1
ohblahitsme ohblahitsme is offline Offline
Newbie Poster

Re: pygame window not werking

 
1
  #7
Jan 3rd, 2009
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 .
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
  #8
Jan 4th, 2009
Just typing at the interpreter so far, but I'll try loading a file. BRB.

[Edit]
Okay, it works. This seems a bit off to me; if I call the update() function it ought to do what it's supposed to, regardless of where the interpreter's input is coming from.
Well, now I know. Thank you!!

  1. import pygame
  2.  
  3. pygame.init()
  4. a = pygame.display.set_mode((300, 300))
  5.  
  6. pygame.draw.circle(a, (255, 255, 255), (100, 100), 20)
  7. pygame.display.update()
  8.  
  9. foo = raw_input() # could just as well have used sleep()
  10.  
  11. pygame.quit()
  12. quit()
Last edited by Nuez_Jr; Jan 4th, 2009 at 3:31 am. Reason: checking out oblahitsme's recommendation
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 2
Reputation: ohblahitsme is an unknown quantity at this point 
Solved Threads: 1
ohblahitsme ohblahitsme is offline Offline
Newbie Poster

Re: pygame window not werking

 
0
  #9
Jan 4th, 2009
I don't remember the full syntax, nor if it is actually what you are looking for but try
  1. pygame.display.flip()
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,275
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 175
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Re: pygame window not werking

 
0
  #10
Jan 4th, 2009
If you want the window to stay open and allow for a graceful exit procedure, you need to set up a simple event loop at the end of the program:
  1. # a simple pygame example
  2. # creates a white circle on a black background
  3. # the event loop makes exit from the program easier
  4.  
  5. import pygame
  6.  
  7. pygame.init()
  8.  
  9. # create a 300 x 300 display window
  10. win = pygame.display.set_mode((300, 300))
  11.  
  12. white = (255, 255, 255)
  13. center = (100, 100)
  14. radius = 20
  15. pygame.draw.circle(win, white, center, radius)
  16.  
  17. # this puts the circle on the display window
  18. pygame.display.flip()
  19.  
  20. # event loop and exit conditions (windows x click)
  21. while True:
  22. for event in pygame.event.get():
  23. if event.type == pygame.QUIT:
  24. raise SystemExit
No one died when Clinton lied.
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
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC