473,471 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

[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 2063
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.