[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Quit pygame



Add "while running:" before the "for" loop. Then when you close the
window, it will quit.

If you want to use standard keys to quit, you have to watch for those in
the event loop as well.

I would check out some of the games on the pygame.org website for
examples. That helped me quite a bit.


On Thu, 30 Sep 2010 18:01:34 +0200, Massimo Di Stefano
<massimodisasha@xxxxxxxx> wrote:
> I tried the following code in a standard python shell :
> 
>>>> from pygame.locals import *
>>>> import pygame
>>>> pygame.init()
> Leopard libedit detected.
> (6, 0)
>>>> for event in pygame.event.get():
> ...     if event.type == QUIT:
> ...         running = False
> ... 
>>>> pygame.event.pump()
>>>> pygame.quit()
>>>> 
> 
> 
> but the "icon" persists on my dok
> if i try to exit from it (right click on the pygame icon) 
>  i have as option only :
> 
> force quit
> 
> that give me a quit of all the python session.
> it print :
>>>> Killed
> and leave me in the bash shell.
> 
> 
> 
> Il giorno 30/set/2010, alle ore 17.47, Lenard Lindstrom ha scritto:
> 
>> Yes, you can try pygame.event.pump() before calling pygame.quit().
>> pygame.quit() does close SDL, so if the icon remains then it is an SDL
>> quirk.
>> 
>> Lenard Lindstrom
>> 
>> On 30/09/10 06:30 AM, Dan Ross wrote:
>>> If I'm not mistaken, you have to have an event loop that watches for
the
>>> pygame.quit() event.
>>> 
>>> for event in pygame.event.get():
>>>             if event.type == QUIT:
>>>                running = False
>>> 
>>> Something like that.
>>> 
>>> Dan
>>> 
>>> On Thu, 30 Sep 2010 12:05:26 +0200, Massimo Di Stefano
>>> <massimodisasha@xxxxxxxx>  wrote:
>>>   
>>>> Hello All,
>>>> 
>>>> 
>>>> i'm having a problem with pygame, ... i don't know ho to quit a
pygame
>>>> session :-(
>>>> 
>>>> i'm on osx 10.6.4
>>>> from a standard python shell, i'm able to start a pygame session,
>>>>     
>>> running
>>>   
>>>> :
>>>> 
>>>> - import pygame ; from pygame.locals import * ; pygame.init()
>>>> 
>>>> 
>>>> MacBook-Pro-15-di-sasha:~ sasha$ python
>>>> Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
>>>> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
>>>> Type "help", "copyright", "credits" or "license" for more
information.
>>>>     
>>>>>>> import pygame
>>>>>>> from pygame.locals import *
>>>>>>> pygame.init()
>>>>>>>           
>>>> Leopard libedit detected.
>>>> (6, 0)
>>>>     
>>>>>>>           
>>>> 
>>>> the previouse instructions opens a nice pygame icon on my dock
>>>> the problem is that i don't know how to "quit" it.
>>>> 
>>>> Tyring to stop the pygame session using :
>>>> 
>>>>  pygame.quit()
>>>> 
>>>> i have no actions ... pygame is still running and i'm not able to
stop
>>>>     
>>> it.
>>>   
>>>> To quit the pygame session i have to quit the python session itself
...
>>>>     
>>> or
>>>   
>>>> foce-quit the app (that always will close my python session)
>>>> 
>>>> have you any hints on how to quit a pygame session without the needs
of
>>>> exit from python ?
>>>> 
>>>> thanks !
>>>> 
>>>> 
>>>> beste regards,
>>>> 
>>>> Massimo.
>>>>     
>>