473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ 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,4 80))
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 2073
On 2005-04-26, Brent W. Hughes <br**********@c omcast.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,4 80))
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**********@c omcast.net> wrote in
news:1t******** ************@co mcast.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,4 80))
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.po ll().type != KEYDOWN:
pygame.time.del ay(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
2499
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 using MacPython, except that I can't seem to get its Package Manager to work. Anyway, when I try to install numeric, I get the following error: chriswei% sudo ./setup.py install Password: running install running build
12
16107
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", pygame.mixer.get_num_channels() pygame.mixer.music.set_volume(1.0) pygame.mixer.music.load('file1.mp3)
3
3712
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 Pygame to manage the image window, as it was the easiest way to implement the functionality I needed. The surrounding interface windows (there are two) are constructed with Tkinter. Despite their unholy union, Pygame and Tkinter seem, generally,...
0
1052
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 Pygame extension modules are built with MinGW. They link cleanly against msvcr71.dll. A custom SDL, also linked to msvcr71.dll, is used. It is built with Msys/MinGW using the configure/make tool chain. For Python 2.6 I expect Visual Studio 2008...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8339
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8629
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2757
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.