Some example code:

Try:
    While running:
          .........pygame.update .....etc
    Pygame.quit
Except exception:
      Pygame.quit()
      Raise

That way even if it errors we still call pygame.quit(), which is what isn't 
happening since the idle doesn't call garbage collection on some code on error. 




> On Aug 26, 2015, at 14:23, Paul Vincent Craven <p...@cravenfamily.com> wrote:
> 
> When using Wing, I teach students to hit the red 'stop' button. The issue is 
> when the process errors, it does not quit, it pauses. Thus the windows stays 
> open and is unresponsive. By hitting the red square 'stop' button, you kill 
> the process.
> 
> Paul Vincent Craven
> 
>> On Wed, Aug 26, 2015 at 1:29 PM, bw <stabbingfin...@gmail.com> wrote:
>> I agree with Ian. You should just be able to allow the script to end without 
>> special closure. But you may also use sys.exit() and quit(). pygame.quit() 
>> is not usually needed, unless you intend to quit pygame and let the program 
>> continue onto something else.
>> 
>> What you're seeing, Bob, may be a problem with the IDE.
>> 
>> There is consensus that IDLE is bad. It creates weird problems (with pygame 
>> only? not sure how far it goes). Annoyances like those with IDLE will likely 
>> turn your students off of Python.
>> 
>> I don't know about WingIDE. You could try a different one. I really like 
>> PyCharm, but it is vast in features and a memory hog--possibly not ideal for 
>> beginners and school computers.
>> 
>> For learning you might consider going with a light syntax-highlighting 
>> editor and teaching students the use of the discrete pieces that an IDE 
>> integrates for you. In other words teach fundamentals and let an IDE be an 
>> elective choice for later. When it comes to ferreting out problems in the 
>> dev environment, one needs to know what is going on behind the IDE. For me 
>> it was very useful learning nuts and bolts, and then discovering what more 
>> an IDE can do for me.
>> 
>> Hope these tips are helpful.
>> 
>> bw
>> 
>> 
>>> On 8/26/2015 10:55 AM, Ian Mallett wrote:
>>>> On Wed, Aug 26, 2015 at 11:38 AM, Bob Irving <bob...@gmail.com> wrote:
>>>> Is there a way to exit your game gracefully when there are errors? We have 
>>>> found with both IDLE and WingIDE that the game hangs, requiring several 
>>>> clicks of the X, etc.
>>>> 
>>>> We are ending our game loop with 
>>>> 
>>>> pygame.quit()
>>>> sys.exit()
>>> ​I prefer to let the script terminate itself (i.e. fall out the bottom), 
>>> but sys.exit should work fine too. I remember having this issue with older 
>>> versions of Python, but 2.7 or 3.* should work fine.
>>> 
>>> Here's some skeleton code that I use.
>>> 
>>> Ian
> 

Reply via email to