473,219 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

[pygame] Very simple program fails. Why?

I'm just starting to learn pygame. I write what I think is just about the
simplest program that should display a window and then quit.
#-----------------------------------------------
import sys
import time
import pygame

pygame.init()
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption("A Bug's Life")
time.sleep(4)
#-----------------------------------------------
When I run this program from within PythonWin, the Bug's Life window appears
and everything looks okay, but after 4 seconds the window still persists.
When I finally close it using the close box in the upper right of the
window, a box pops up telling me an error occurred ant it wants to send a
report to Microsoft. I click "Don't send" and another box pops up telling
me that the program was trying to access memory location 0x1c.

If I try to run the program stand-alone (outside of PythonWin), a DOS box
pops up for a second or two, then the Bug's Life window flashes up for a
fraction of a second, and then both windows disappear.

Am I doing something wrong?

Brent

Jul 19 '05 #1
2 2055
On 2005-04-26, Brent W. Hughes <br**********@comcast.net> wrote:
I'm just starting to learn pygame. I write what I think is just about the
simplest program that should display a window and then quit.
#-----------------------------------------------
import sys
import time
import pygame

pygame.init()
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption("A Bug's Life")
time.sleep(4)
#-----------------------------------------------
When I run this program from within PythonWin, the Bug's Life window appears
and everything looks okay, but after 4 seconds the window still persists.
When I finally close it using the close box in the upper right of the
window, a box pops up telling me an error occurred ant it wants to send a
report to Microsoft. I click "Don't send" and another box pops up telling
me that the program was trying to access memory location 0x1c.

If I try to run the program stand-alone (outside of PythonWin), a DOS box
pops up for a second or two, then the Bug's Life window flashes up for a
fraction of a second, and then both windows disappear.

Am I doing something wrong?

Works perfectly for me on Linux, but that does not help
you much... If no one helps you out further here, make
your way over to the pygame mailing list. Someone will
be able to spot the problem:
http://pygame.org/info.shtml#maillist
Jul 19 '05 #2
"Brent W. Hughes" <br**********@comcast.net> wrote in
news:1t********************@comcast.com:
I'm just starting to learn pygame. I write what I think is just about
the simplest program that should display a window and then quit.
#-----------------------------------------------
import sys
import time
import pygame

pygame.init()
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption("A Bug's Life")
time.sleep(4)
#-----------------------------------------------


Two problems here - first is that you should always call
pygame.display.quit() when done. The second is that if you sleep(4)
you've effectively blocked off the event loop for that process, which
makes Windows unhappy. Even clicking 'close' to close the window won't
work. Your very dumbest pygame program should have a loop like:

while pygame.event.poll().type != KEYDOWN:
pygame.time.delay(10)

Which just does nothing (but pumps the event loop) until a key is
pressed, then exits.

Or you could add up the spent time and bail when it hits four seconds, or
whatever you want, but you should be doing something with the
pygame.event loop. And then call the pygame.display.quit() when done of
course.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Weisiger | last post by:
I'm trying to install numeric on my MacOS X box using Darwin, with the eventual goal of satisfying all of PyGame's dependencies so I can finally start working on my semester project. I would be...
12
by: Marian Aldenhövel | last post by:
Hi, I am trying to make pygame play music on windows. This simple program: import pygame,time pygame.init() print "Mixer settings", pygame.mixer.get_init() print "Mixer channels",...
3
by: Tim Knauf | last post by:
Hi everyone, I'm glad to have found this list. I've written a small script for my own use which, amongst other things, captures mouse click information from a window containing an image. I used...
0
by: L. Lindstrom | last post by:
I build the Pygame releases for Windows. Pygame wraps the Simple Directmedia Layer (SDL) C library. I am doing preliminary research into porting Pygame to Python 2.6. For Pythons 2.4 and 2.5 the...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.