diff options
author | Guido van Rossum <guido@python.org> | 1995-02-20 23:42:50 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-02-20 23:42:50 (GMT) |
commit | 4cbb0e3a2dcaa6b850b55af829f28e8bf4d4c22b (patch) | |
tree | 34d2dc2468d4c54039ee2d92c55b0f4c7ab911b6 /Mac | |
parent | 156380e382daf03aeec37a3736da24b8e7473ae9 (diff) | |
download | cpython-4cbb0e3a2dcaa6b850b55af829f28e8bf4d4c22b.zip cpython-4cbb0e3a2dcaa6b850b55af829f28e8bf4d4c22b.tar.gz cpython-4cbb0e3a2dcaa6b850b55af829f28e8bf4d4c22b.tar.bz2 |
applet to run any script
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/scripts/run.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Mac/scripts/run.py b/Mac/scripts/run.py new file mode 100644 index 0000000..86da024 --- /dev/null +++ b/Mac/scripts/run.py @@ -0,0 +1,35 @@ +# Script (applet) to run any Python command + +def main(): + import sys + del sys.argv[:1] + if not sys.argv: + import macfs + srcfss, ok = macfs.StandardGetFile('TEXT') + if not ok: + return + filename = srcfss.as_pathname() + sys.argv.append(filename) + import __main__ + try: + execfile(sys.argv[0], __main__.__dict__) + except SystemExit, msg: + if msg: + message("Exit status: %s" % str(msg)) + sys.exit(msg) + except: + etype = sys.exc_type + if hasattr(etype, "__name__"): etype = etype.__name__ + message("%s: %s" % (etype, sys.exc_value)) + sys.exit(1) + +def message(str = "Hello, world!", id = 129): + import Dlg + d = Dlg.GetNewDialog(id, -1) + tp, h, rect = d.GetDItem(2) + Dlg.SetIText(h, str) + while 1: + n = Dlg.ModalDialog(None) + if n == 1: break + +main() |