-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.py
More file actions
executable file
·41 lines (33 loc) · 1016 Bytes
/
page.py
File metadata and controls
executable file
·41 lines (33 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Python wrapper for executing PAGE. Running under Python removes the
# requirement of installing Tcl/Tk. Python 3 is required for running
# PAGE and the Python modules generated by PAGE.
import sys
import os, os.path
try:
import tkinter as tk
py_version = 3
except ImportError:
import Tkinter as tk
import tkMessageBox
py_version = 2
print("py_version = %s" % py_version)
if py_version < 3:
root = tk.Tk()
root.withdraw()
tkMessageBox.showerror("Error", "Python 3 required!\nExiting.")
sys.exit(1)
root.mainloop()
root = tk.Tk()
root.withdraw()
root.tk.eval('set argv {}; set argc 0')
p = os.path.abspath(sys.argv[0])
cmd = "source {" + os.path.join(os.path.dirname(p), 'page.tcl') + "}"
for a in sys.argv[1:]: # Skip argv[0] (the filename of this script)
# root.tk.eval(f'lappend argv {{{a}}}; incr argc')
root.tk.eval("lappend argv {%s}; incr argc" % a)
try:
root.tk.eval(cmd)
sys.exit()
except:
pass
root.mainloop()