Quit function in python program -


I have a program that runs in python, without a console (which is to say, I use it py2exe Is compiled). I want people to get out of the main menu, or from a particular key-in-game (e.g., Shift + Q). I'm running it, for now, in Windows, though I'm working on the Linux / Mac version compilation. I think if a 'loop' is going on, and it closes correctly, then The X works by pressing the button, otherwise it seems that stop waiting until the current command closes 'Store'.

Menu options, I have seen well through the document and the Stakeoverflow and have tried to quit (), exit (), sys.exit () and every combination I can find, but Every time I get:

  Traceback (the most recent call final): File "Alfaith Yu Y", line 61177, & lt; Module & gt; Error in the file "alphatime.pyw", line 53970, place_menu: Global name 'sys' is not defined  

If I try sys.exit, and after that:

  traceback (most recent call final): file "alphatime.pyw", line 61177, & lt; Module & gt; Error in the file "alphatime.pyw", line 53970, place_menu: Global name 'left' is not defined  

If I just try "quit" Need to shut down has heard things about 'installation', but I'm not telling the meaning (I am new in Python) and how I will do it.

So, my question is two times.

First of all, can I put in the loop to identify some such things that 'X' can be clicked and closed?

Second, is there a proper command that will close the program? I do not understand why these orders do not work, and I had a lot of complaints from people who used the program, who crashed it, or ctrl-alt-del, or whatever I believe

  try import: Excluding os._exit (return_code) will work: pass  

but at this time, I'm not sure I 'd enable enough on the python to deploy it properly thanks in advance!

You did it at any time

  import sys  

Because it should work!


Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -