[Tutor] pausing time and perform on exit

Magnus Lycka magnus@thinkware.se
Thu Oct 31 20:45:01 2002


At 20:04 2002-10-31 -0500, Kyle Babich wrote:
>I actually have two questions--first do date I have never figured out how to
>pause time.

You can do this at will. As soon as you want to pause
time, it actually does that. But since this will also
pause your mental processes together with everything
else, neither you nor anyone else will ever notice! It's
just you who can do this Kyle, and noone ever notices...
What does this have to do with Python? ;)

>The best of come up with is simple while loops that look for
>something to happen but its fair to say I'm clueless.
>
>timetosleep = 0
>while timetosleep < 60:
>     time.sleep(1)
>     timetosleep += 1

Why is this better than "time.sleep(60)" ?

Can you explain a little more what you are trying to achieve?

>Also how would I tell the program to do something when the program is exited
>by having the window closed to the computer shut down (anything with the
>user manually typing 'quit' into the program)?  I don't even know where to
>begin with this.

If you write a GUI program, there will be special
close events that you can bind to a function. I'm
not sure I fully understand your question though.

There is also some general hook for exiting python
programs... Hm... Check the library reference for
sys.exitfunc() and the atexit module.

I don't think there is anything you can do to save
things when the program is being shot down with a
signal though. For a non-gui program I think this
is what happens on computer shutdown.

Or do you just want to stop your program? You have
to explain better...


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se