| | |
pygame window not werking
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jan 2006
Posts: 5
Reputation:
Solved Threads: 0
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...
im using windows XP
any ideas?
Python Syntax (Toggle Plain Text)
import os, sys, pygame from pygame.locals import * pygame.init() window = pygame.display.set_mode((420,280)) #everything here after does nothing to the window pygame.display.set_caption("my window") #etc...
im using windows XP
any ideas?
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Solved Threads: 1
•
•
•
•
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...
Python Syntax (Toggle Plain Text)
import os, sys, pygame from pygame.locals import * pygame.init() window = pygame.display.set_mode((420,280)) #everything here after does nothing to the window pygame.display.set_caption("my window") #etc...
im using windows XP
any ideas?
Try to use something like drPython or Boa as an editor.
Peter.
http://www.pkort.nl
Did you put the event loop in? This is a code sample of a very basic pygame program ...
python Syntax (Toggle Plain Text)
import pygame from pygame.locals import * yellow = (255,255,0) # RGB color tuple # initialize screen pygame.init() screen = pygame.display.set_mode((350, 250)) pygame.display.set_caption('Basic Pygame program') # fill background background = pygame.Surface(screen.get_size()) background = background.convert() background.fill(yellow) # display some text font = pygame.font.Font(None, 36) text = font.render("Hello from Monty PyGame", 1, (10, 10, 10)) textpos = text.get_rect() textpos.centerx = background.get_rect().centerx background.blit(text, textpos) # blit everything to the screen screen.blit(background, (0, 0)) pygame.display.flip() # event loop while 1: for event in pygame.event.get(): if event.type == QUIT: raise SystemExit screen.blit(background, (0, 0)) pygame.display.flip()
Last edited by vegaseat; Aug 27th, 2007 at 7:58 pm. Reason: php-->python tag
May 'the Google' be with you!
•
•
Join Date: Aug 2007
Posts: 1
Reputation:
Solved Threads: 1
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.
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.
This would be a very basic pygame program, see if you can get that to work:
python Syntax (Toggle Plain Text)
# fooling around with pygame --> draw/fill some rectangles import pygame as pg # initiate pygame first pg.init() #create a 400x300 window screen = pg.display.set_mode((400, 300)) # give it a title pg.display.set_caption('Draw/fill rectangles using pygame') # some color constants white = 0xFFFFFF red = 0xFF0000 green = 0x00FF00 blue = 0x0000FF yellow = 0xFFFF00 #draw/fill a 77x33 rectangle in position x=250, y=50 (NW corner) screen.fill(white, (250, 50, 77, 33)) # more rectangles, vary color, size, position ... screen.fill(red, (30, 20, 70, 120)) screen.fill(red, (140, 70, 90, 80)) screen.fill(green, (150, 80, 70, 60)) screen.fill(yellow, (200, 170, 150, 60)) screen.fill(blue, (70, 200, 100, 70)) # hey, nothing gets displayed until one updates the screen pg.display.update() # create the event loop to get things going # and specify an exit action (clicking on the window x) while True: for event in pg.event.get(): if event.type == pg.QUIT: raise SystemExit
drink her pretty
(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.
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.
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.
Python Syntax (Toggle Plain Text)
import pygame a = pygame.display.set_mode((400, 300)) # the surface window appears in both cases # it's grey and unavailable when I invoke python.exe (Windows version) from bash # the background is filled with black, but still unavailable when I invoke python.exe from CMD pygame.draw.circle(a, (255, 255, 255), (100, 100), 20) pygame.display.flip() # nothing happens pygame.quit() # surface window eventually disappears # under CMD -only-, the white circle appears briefly just before the window closes # 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.
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!!
[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!!
Python Syntax (Toggle Plain Text)
import pygame pygame.init() a = pygame.display.set_mode((300, 300)) pygame.draw.circle(a, (255, 255, 255), (100, 100), 20) pygame.display.update() foo = raw_input() # could just as well have used sleep() pygame.quit() quit()
Last edited by Nuez_Jr; Jan 4th, 2009 at 3:31 am. Reason: checking out oblahitsme's recommendation
•
•
Join Date: Jan 2009
Posts: 2
Reputation:
Solved Threads: 1
I don't remember the full syntax, nor if it is actually what you are looking for but try
Python Syntax (Toggle Plain Text)
pygame.display.flip()
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:
python Syntax (Toggle Plain Text)
# a simple pygame example # creates a white circle on a black background # the event loop makes exit from the program easier import pygame pygame.init() # create a 300 x 300 display window win = pygame.display.set_mode((300, 300)) white = (255, 255, 255) center = (100, 100) radius = 20 pygame.draw.circle(win, white, center, radius) # this puts the circle on the display window pygame.display.flip() # event loop and exit conditions (windows x click) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: raise SystemExit
No one died when Clinton lied.
![]() |
Similar Threads
- More pygame trouble. Toggle window not working. (Python)
- Pygame crashing (Python)
- JavaScript's window.opener (JavaScript / DHTML / AJAX)
- I need window~1.ani (Windows NT / 2000 / XP)
Other Threads in the Python Forum
- Previous Thread: Class module help
- Next Thread: Google Results and Python
| Thread Tools | Search this Thread |
abrupt ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog decimals dictionaries dictionary directory drive dynamic error examples excel exe file float format function gnu graphics gui heads homework http ideas import input java launcher leftmouse line linux list lists logging loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyqt python random recursion schedule scrolledtext sqlite statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial twoup ubuntu unicode update urllib urllib2 variable ventrilo wikipedia windows write wxpython xlib






. 