|
From: GoWtHaM N. <nar...@gm...> - 2009-03-05 09:24:27
|
Hi All,
I am looking at a way to gracefully closing the PythonCard application and
report back as log give some information or do the clean up before ending
the script.
To present a sample, heres some code written over minimal.py script.
====================================================
from PythonCard import model
class Minimal(model.Background):
def on_initialize(self, e):
self.test = 'test code'
print 'Inside Init'
if __name__ == '__main__':
app = model.Application(Minimal)
print help(app)
#app.RedirectStdio('output.txt')
try:
app.MainLoop()
print 'Action after the loop'
except (KeyboardInterrupt, SystemExit):
print 'Program execution has been stopped by keyboard interrupt'
====================================================
It never prints the statement in except whenever I end the program with ctrl
+ c.
On a normal loop, like this- It works and prints the statement..
==========================
import time
try:
while 1:
time.sleep(1)
except KeyboardInterrupt:
print 'Program execution has been stopped by keyboard interrupt'
===========================
Is there an alternate way of doing this so that I can capture the keyboard
interrupt before the script closes.
Thanks,
Gowtham N
|