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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/python
import sys
import os
import gtk
import linuxcnc
from gremlin import Gremlin
def W(p, k, *args, **kw):
w = k(*args, **kw)
w.show()
p.add(w)
return w
class GremlinApp(gtk.Window):
def __init__(self, inifile):
if not inifile:
inifile = os.environ.get('INI_FILE_NAME', None)
if not inifile:
usage()
try:
inifile = linuxcnc.ini(inifile)
except linuxcnc.error,detail:
usage('Using filename = %s\n %s' % (inifile,detail))
gtk.Window.__init__(self)
self.vbox = W(self, gtk.VBox)
self.gremlin = W(self.vbox, Gremlin, inifile)
self.gremlin.set_size_request(400, 400)
self.connect("destroy", self.quit)
self.show()
def quit(self, event):
gtk.main_quit()
def usage(msg=None):
print('Usage: %s inifilename' % sys.argv[0])
print(' or: %s (requires environmental variable INI_FILE_NAME)'
% sys.argv[0])
if msg:
print('\n%s' % msg)
sys.exit(1)
def main():
if len(sys.argv) == 1:
inifilename = None
elif len(sys.argv) == 2:
inifilename = sys.argv[1]
else:
usage()
g = GremlinApp(inifilename)
gtk.main()
if __name__ == '__main__': raise SystemExit, main()
|