Applied one other trick to use the Tk command "font measure" to
[xcircuit.git] / lib / python / loadlgf.py
blob723e197bf2676736cc5ebed79f0144b098d99037
1 # loadlgf.py
2 #-----------------------------------------------------------
3 # Python script which creates a function "loadlgf" that
4 # replaces the code formerly in "formats.c" (deprecated).
5 # Python scripting is now the preferred method for handling
6 # alternate file formats.
7 #-----------------------------------------------------------
9 def loadlgf(f):
10 try:
11 fi = open(f, 'r')
12 except IOError:
13 return
14 else:
16 # check magic cookie to see if it's a real LGF file
18 S = fi.readline()
19 if (S <> '-5\n'):
20 return
22 S = fi.readline()
23 if (S <> 'f s\n'):
24 return
26 # Now go load the LGF library (required)
27 # '-1' loads at the end of the current library pages
29 library('lgf.lps', -1)
31 # clear the page
33 reset()
35 # read in the file
37 S = fi.readlines()
38 for X in S:
39 if (S[0] == '#'):
40 elif (S[0] == 'n'):
41 elif (S[0] == 's'):
42 elif (S[0] == 'l'):
43 elif (S[0] == 'w'):
44 elif (S[0] == 'p'):
45 elif (S[0] == 'b'):
46 elif (S[0] == 'g'):
47 elif (S[0] == 'h'):
48 elif (S[0] == '.'):
49 else:
51 h1 = getpage();
52 return h1
54 def promptlgf():
55 filepopup('Enter filename to load:', 'loadlgf')
57 bind('Control_l', 'promptlgf')
58 newbutton('Edit', 'Load LGF File (^L)', 'promptlgf')
60 #-----------------------------------------------------------