Re: [pygame] font initialization error
Did you initialize the font system with pygame.font.init() or just pygame.init() Fonts should work after that. On 10/11/07, AlgoMantra [EMAIL PROTECTED] wrote: Hi All, I keep getting an error from the myfont = pygame.font.SysFont(Vera, 12) line saying Error: Font not Initialized. Could anyone tell me what is wrong here? I'm using Python2.5 on XP. -- ----.- 1/f ))) --. ---... http://www.algomantra.com
Re: [pygame] font initialization error
Thanks Kyle. I had not initialized the font system. It works after I included pygame.font.init() I have a couple of other issues with the code I'm working on right now. 1. if event.type == pygame.QUIT: sys.exit() I'm using this to close the Pygame window, but it always sort of hangs and then a pop up saying this program is not responding. pythonw.exe nonresponsive etc. Why is it this way? 2. In the running loop of the program, I'm using a function to blit text to background.blit(text, textpos) And the text in each case has to be new, that is a new value. But my current code is just rewriting the text on top of the old value, creating a mess. Is there a way to refresh this? I'll be very grateful for any hints on the above. dj fadereu ----.- 1/f ))) --. ---... http://www.algomantra.com
Re: [pygame] font initialization error
1. if event.type == pygame.QUIT: sys.exit() You may be better off also telling pygame to shutdown. This won't help much though if you are running pygame programs from single process IDEs. if event.type == pygame.QUIT: pygame.quit() sys.exit() http://pygame.org/docs/ref/pygame.html#pygame.quit
Re: [pygame] Re: error on mac
I find it's because of the mixer, I use mixer.music to play midi, it seems pygame not support midi well in Mac, now I converted midi to ogg, it worked. It's very strange the error just happen in fullscreen mode when blit a surface. On 10/11/07, Ian Mallett [EMAIL PROTECTED] wrote: I'm not familiar with pygame or python on mac, but a segmentation fault happens when a program tries to read non-existent data from video memory. The only thing I can think of is that your surfaces are invalid; you didn't make them right? Ian -- http://www.flyaflya.com
Re: [pygame] pygamefont problem
A basic look-over seems OK, but I can't find where your font code is? Am I missing something obvious? Also, OpenGL.GLUT is archaic :-) Ian
RE: [pygame] pygame.init before pygame.mixer.init?
I did a little more testing: OS: Windows XP Pygame: I installed v1.7.1 for Win32 and Python 2.5 (http://www.pygame.org/ftp/pygame-1.7.1release.win32-py2.5.exe) I've reproduced the problem on one other WinXP machine with the same Pygame release, but the problem doesn't occur on my WinXP machine at home (the sound plays just fine without pygame.mixer.init). I've been able to determine that pygame.mixer.get_busy() isn't failing, simply by replacing pass with print Hello. Calling pygame.mixer.pre_init() instead of pygame.mixer.init doesn't get play any sound. *But* sound will play without pygame.mixer.init if I call pygame.display.set_mode AND put a time delay between loading the sound and playing it: -- import pygame pygame.init() screen = pygame.display.set_mode((500,500)) sound = pygame.mixer.Sound(dog.wav) pygame.time.delay(1000) sound.play() while pygame.mixer.get_busy(): pass -- A few questions this brings up: * Why does setting the display make a difference, and why does this fix the problem of having to call pygame.mixer.init first? * Why does it take too long to load the sound, such that it won't play if I call it immediately? And why does calling pygame.mixer.init first make this problem go away? -- Clare Richardson -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Clare Richardson Sent: Wednesday, October 10, 2007 2:55 PM To: pygame-users@seul.org Subject: [pygame] pygame.init before pygame.mixer.init? I writing a program to simply play one sound (see below for the code), and came across some interesting behavior. If I call pygame.init() before pygame.mixer.init(), I don't hear any sound playing. However if I call pygame.init *after* pygame.mixer.init (as below), the sound will play. Is this a known behavior? What's causing the problem? I understand that I don't need pygame.init to just play a sound, but I don't think it should matter if I call it. Thanks! Clare Richardson --- import pygame pygame.mixer.init() pygame.init() sound = pygame.mixer.Sound(bark.wav) sound.play() while pygame.mixer.get_busy(): pass pygame.mixer.quit()
Re: [pygame] font initialization error
On 10/11/07, AlgoMantra [EMAIL PROTECTED] wrote: I'm using this to close the Pygame window, but it always sort of hangs and then a pop up saying this program is not responding. pythonw.exe nonresponsive etc. Why is it this way? If you open with edit with IDLE and use F5, the program will crash on exiting. Does this problem occur when you double-click on the program's icon in a finder window? And the text in each case has to be new, that is a new value. But my current code is just rewriting the text on top of the old value, creating a mess. Is there a way to refresh this? There is no way to delete something you've drawn on the screen. To completely refresh the screen, use surface.fill(#background colour) before you draw anything. I'm not sure if that's your problem though. Could you be more specific? Ian
Re: [pygame] Re: error on mac
On Thu, Oct 11, 2007 at 12:11:30PM -0700, Ian Mallett wrote: On 10/11/07, flyaflya [EMAIL PROTECTED] wrote: I find it's because of the mixer, I use mixer.music to play midi, it seems pygame not support midi well in Mac, now I converted midi to ogg, it worked. Well, for one thing, midi shouldn't work. It says only .wav or .ogg here: http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.Sound pygame.mixer.sound only supports wav and ogg, but pygame.mixer.music should play anything supported by SDL_Mixer, which IIRC includes: wav ogg mp3 midi mod xm it s3m and maybe some others. I have successfully played midi on mac using pygame.mixer.music Format availability may vary depending on how your SDL_Mixer library was compiled. --- James Paige
Re: [pygame] pygame.init before pygame.mixer.init?
Hi Clare, I still think it is the same problem as before. The get_busy is only busy when the file is playing. You have delayed it to allow the file to Queue in and that has fixed it. If your hard drive is slow that would cause it. Most things on the screen will not become active until the screen is active and that to is part of the issue. Whether threading is an issue, which allows somethings to move on while other things are still stuck in the mud has its problems... Besides loading the initial package, load all the other packages. I am not sure, but I think some of the other packages have a better mixer in it. You may just have a timing issue between machines that is being caught on an accumulation of issues. That may cause a problem in cross platform compatibility, but the get_busy is only active while a file is playing. It must be playing first for it to work. If not, you will just run through that while statement as if nothing ever played. The reason why putting a delay in has fixed the issue. You allowed the file to actually start playing so the busy is busy! Bruce I did a little more testing: OS: Windows XP Pygame: I installed v1.7.1 for Win32 and Python 2.5 (http://www.pygame.org/ftp/pygame-1.7.1release.win32-py2.5.exe) I've reproduced the problem on one other WinXP machine with the same Pygame release, but the problem doesn't occur on my WinXP machine at home (the sound plays just fine without pygame.mixer.init). I've been able to determine that pygame.mixer.get_busy() isn't failing, simply by replacing pass with print Hello. Calling pygame.mixer.pre_init() instead of pygame.mixer.init doesn't get play any sound. *But* sound will play without pygame.mixer.init if I call pygame.display.set_mode AND put a time delay between loading the sound and playing it: -- import pygame pygame.init() screen = pygame.display.set_mode((500,500)) sound = pygame.mixer.Sound(dog.wav) pygame.time.delay(1000) sound.play() while pygame.mixer.get_busy(): pass -- A few questions this brings up: * Why does setting the display make a difference, and why does this fix the problem of having to call pygame.mixer.init first? * Why does it take too long to load the sound, such that it won't play if I call it immediately? And why does calling pygame.mixer.init first make this problem go away? -- Clare Richardson -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Clare Richardson Sent: Wednesday, October 10, 2007 2:55 PM To: pygame-users@seul.org Subject: [pygame] pygame.init before pygame.mixer.init? I writing a program to simply play one sound (see below for the code), and came across some interesting behavior. If I call pygame.init() before pygame.mixer.init(), I don't hear any sound playing. However if I call pygame.init *after* pygame.mixer.init (as below), the sound will play. Is this a known behavior? What's causing the problem? I understand that I don't need pygame.init to just play a sound, but I don't think it should matter if I call it. Thanks! Clare Richardson --- import pygame pygame.mixer.init() pygame.init() sound = pygame.mixer.Sound(bark.wav) sound.play() while pygame.mixer.get_busy(): pass pygame.mixer.quit()
[pygame] BUG: load_xbm won't take 1 argument
my OS is Windows XP SP2 my Python version is 2.5 my pygame version is '1.7.1release' I get this error when trying to load an xbm file: pygame.cursors.load_xbm(windowsno.xbm) TypeError: load_xbm() takes exactly 2 arguments (1 given) i also tried pygame.cursors.load_xbm(windowsno.xbm, None) (even though the second argument should default to None according to the documentation), and it said NoneType has no attribute readline.so it insists on having a second file, but i only have one file i want to load.
[pygame] cursors strings should have hotspot and size info
It would be nice if * pygame.cursors.thickarrow_strings * pygame.cursors.sizer_x_strings * pygame.cursors.sizer_y_strings * pygame.cursors.sizer_xy_strings came with hotspot and size info. especially hotspot.
Re: [pygame] pygame.init before pygame.mixer.init?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 RR4CLB wrote: Hi Clare, I still think it is the same problem as before. The get_busy is only busy when the file is playing. You have delayed it to allow the file to Queue in and that has fixed it. If your hard drive is slow that would cause it. Most things on the screen will not become active until the screen is active and that to is part of the issue. Whether threading is an issue, which allows somethings to move on while other things are still stuck in the mud has its problems... To the best of my knowledge, when pygame.mixer.Sound() returns a Sound object, this means the file has been read. No queueing happens here, though it might for pygame.mixer.music. Besides loading the initial package, load all the other packages. I am not sure, but I think some of the other packages have a better mixer in it. As far as I know, there is only one pygame.mixer. There is also pygame.mixer.music, but I don't think it's what Clare Richardson is looking for. You may just have a timing issue between machines that is being caught on an accumulation of issues. That may cause a problem in cross platform compatibility, but the get_busy is only active while a file is playing. It must be playing first for it to work. If not, you will just run through that while statement as if nothing ever played. The reason why putting a delay in has fixed the issue. You allowed the file to actually start playing so the busy is busy! I think you might have misread Clare Richardson's post: I've been able to determine that pygame.mixer.get_busy() isn't failing, simply by replacing pass with print Hello. This suggests strongly that in all cases, the file is completely loaded into memory, and that pygame.mixer is correctly figuring out how long the sound should be playing, and even playing, but that somehow the sound isn't going anywhere. I'm not an expert on pygame internals, especially on Windows, but the fact that it works better after calling pygame.display.set_mode() reminds me of some problems people used to have focusing on DirectX windows. Namely: the application doesn't get access to sound, graphics, etc. until it opens a window. However, my vague recollection was also that DirectX was not the default any more. To force a non-DirectX audio driver, you could try doing something like: import pygame, os os.environ['SDL_AUDIODRIVER'] = waveout' before doing any pygame*.init(). As you may have gathered, I have no idea if this will actually work. Ethan -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHDsEuhRlgoLPrRPwRAgXcAKC4hKmhx4uqHl3np7UGGMhXVUcX7QCdH3Qj rH7E2DwjA30FDOVLsaPZrmk= =4xyY -END PGP SIGNATURE-
Re: [pygame] pygamefont problem
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 vwf wrote: I think I use old code, but I don't know what is wrong. I include a small programme that works, but displays incorrectly (it is a QD cut from my real programme). Any suggestions, or a pointer to an example I can use? Hi, I've only been playing with pygame for the last few years, but I've never even heard of pygamefont, and Google only has three results for PyGameBitmapFont. My advice to you might be to look at other ways people using PyOpenGL have been doing fonts recently (I'm not at all knowledgeable in this subject). Ethan -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHDsF3hRlgoLPrRPwRAuO4AKDXlFMBtiUfOi3SL4HbB7xnCUbZwwCgqz9g iasXH5wjdYF2HI1Kalr8KG8= =ut5n -END PGP SIGNATURE-
Re: [pygame] Re: error on mac
Ha ha ha! Opps...
Re: [pygame] pygamefont problem
My way of doing it is to get an image of all the characters in a font, then make a bunch of textures for each character you want, then draw them at the near clipping plane.
Re: [pygame] Re: error on mac
Yes, I use pygame.mixer.music to play midi, It work fine in windows, but make program crash in mac after playing a while. Maybe the pygame I used has different versions in windows and mac, I'm not care of this now, I will just use ogg in my game from now, it seem has been best supported. On 10/12/07, Ian Mallett [EMAIL PROTECTED] wrote: Ha ha ha! Opps... -- http://www.flyaflya.com
Re: [pygame] pygame.init before pygame.mixer.init?
# Import the necessary ocempgui parts. from ocempgui.object import ActionListener from ocempgui.widgets import * from ocempgui.widgets.Constants import * from pygame.locals import * import os.path import sys import pygame.mixer, pygame.time #, pygame.key # ALL GLOBAL VARIABLES ARE IN CAPS! Q_MIXER = pygame.mixer Q_TIME = pygame.time Q_Key = pygame.key pygame.init Q_MIXER.pre_init(23024) # DOES NOT WORK! Hi Ethan, Yes and no, but what you eventually mentioned is what I did say. The screen mode being set and also the program she wrote and the delay placed between the loading of the file and queuing it in, setting it into the object. Just look at the example Clare gave and I placed it below. If I am not mistaken, I did read about the get_busy is only good while the sound is playing. Which is what I meant. Also, I have the new stuff loaded and the SDL does have a better setup. I do not know if she has all that loaded or not. But the interesting thing about this is the mixer.init parameters work in a test file I have which has none of the other stuff loaded, just the pygame. But with all the other stuff installed and also imported, the init is ignored. The example of the key inputs I gave I commented them out and it made no difference. I changed the values inside the () and made no difference. But when playing the old test file which goes straight in without loading any other imports the init works and varies with each change of the parameters. Same files, same format, but only difference is the amount of new stuff imported..; I.E. mentioned above at beginning of this email. Bruce Claire's Post: -- import pygame pygame.init() screen = pygame.display.set_mode((500,500)) sound = pygame.mixer.Sound(dog.wav) pygame.time.delay(1000) sound.play() while pygame.mixer.get_busy(): pass -- - Original Message - From: Ethan Glasser-Camp [EMAIL PROTECTED] To: pygame-users@seul.org Sent: Thursday, October 11, 2007 8:34 PM Subject: Re: [pygame] pygame.init before pygame.mixer.init? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 RR4CLB wrote: Hi Clare, I still think it is the same problem as before. The get_busy is only busy when the file is playing. You have delayed it to allow the file to Queue in and that has fixed it. If your hard drive is slow that would cause it. Most things on the screen will not become active until the screen is active and that to is part of the issue. Whether threading is an issue, which allows somethings to move on while other things are still stuck in the mud has its problems... To the best of my knowledge, when pygame.mixer.Sound() returns a Sound object, this means the file has been read. No queueing happens here, though it might for pygame.mixer.music. Besides loading the initial package, load all the other packages. I am not sure, but I think some of the other packages have a better mixer in it. As far as I know, there is only one pygame.mixer. There is also pygame.mixer.music, but I don't think it's what Clare Richardson is looking for. You may just have a timing issue between machines that is being caught on an accumulation of issues. That may cause a problem in cross platform compatibility, but the get_busy is only active while a file is playing. It must be playing first for it to work. If not, you will just run through that while statement as if nothing ever played. The reason why putting a delay in has fixed the issue. You allowed the file to actually start playing so the busy is busy! I think you might have misread Clare Richardson's post: Clare's Post: -- import pygame pygame.init() screen = pygame.display.set_mode((500,500)) sound = pygame.mixer.Sound(dog.wav) pygame.time.delay(1000) sound.play() while pygame.mixer.get_busy(): pass -- I've been able to determine that pygame.mixer.get_busy() isn't failing, simply by replacing pass with print Hello. This suggests strongly that in all cases, the file is completely loaded into memory, and that pygame.mixer is correctly figuring out how long the sound should be playing, and even playing, but that somehow the sound isn't going anywhere. I'm not an expert on pygame internals, especially on Windows, but the fact that it works better after calling pygame.display.set_mode() reminds me of some problems people used to have focusing on DirectX windows. Namely: the application doesn't get access to sound, graphics, etc. until it opens a window. However, my vague recollection was also that DirectX was not the default any more. To force a non-DirectX audio driver, you could try doing something like: import pygame, os os.environ['SDL_AUDIODRIVER'] = waveout' before doing any pygame*.init(). As you may have gathered, I have no idea if
Re: [pygame] Re: error on mac
Me too, .ogg is smaller. Ian