blob: 13c926f3ad73fc959293f9354ad0cce534b97e15 [file] [log] [blame]
Guido van Rossumcd68a2d1991-12-11 17:29:59 +00001#
2# flp - Module to load fl forms from fd files
3#
4# Jack Jansen, December 1991
5#
Brett Cannona45a5612008-05-15 03:20:36 +00006from warnings import warnpy3k
7warnpy3k("the flp module has been removed in Python 3.0", stacklevel=2)
8del warnpy3k
9
Guido van Rossumcd68a2d1991-12-11 17:29:59 +000010import string
Guido van Rossume490d131992-03-31 19:04:48 +000011import os
Guido van Rossumcd68a2d1991-12-11 17:29:59 +000012import sys
Guido van Rossumcd68a2d1991-12-11 17:29:59 +000013import FL
14
15SPLITLINE = '--------------------'
16FORMLINE = '=============== FORM ==============='
17ENDLINE = '=============================='
18
Fred Drake455445a2000-08-18 14:59:33 +000019class error(Exception):
20 pass
Guido van Rossumcd68a2d1991-12-11 17:29:59 +000021
22##################################################################
23# Part 1 - The parsing routines #
24##################################################################
25
26#
27# Externally visible function. Load form.
28#
29def parse_form(filename, formname):
Guido van Rossumb5114ca1992-02-19 14:50:10 +000030 forms = checkcache(filename)
Guido van Rossum2b2e2dc1994-08-23 13:29:21 +000031 if forms is None:
Guido van Rossum3e415c71998-03-26 20:23:01 +000032 forms = parse_forms(filename)
Guido van Rossum2b2e2dc1994-08-23 13:29:21 +000033 if forms.has_key(formname):
Guido van Rossum3e415c71998-03-26 20:23:01 +000034 return forms[formname]
Guido van Rossumb5114ca1992-02-19 14:50:10 +000035 else:
Guido van Rossum3e415c71998-03-26 20:23:01 +000036 raise error, 'No such form in fd file'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +000037
38#
39# Externally visible function. Load all forms.
40#
41def parse_forms(filename):
Guido van Rossumb5114ca1992-02-19 14:50:10 +000042 forms = checkcache(filename)
Fred Drake815a5232000-12-12 23:11:42 +000043 if forms is not None: return forms
Guido van Rossumcd68a2d1991-12-11 17:29:59 +000044 fp = _open_formfile(filename)
45 nforms = _parse_fd_header(fp)
46 forms = {}
47 for i in range(nforms):
Guido van Rossum3e415c71998-03-26 20:23:01 +000048 form = _parse_fd_form(fp, None)
49 forms[form[0].Name] = form
Guido van Rossumb5114ca1992-02-19 14:50:10 +000050 writecache(filename, forms)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +000051 return forms
Guido van Rossumb5114ca1992-02-19 14:50:10 +000052
53#
54# Internal: see if a cached version of the file exists
55#
56MAGIC = '.fdc'
Guido van Rossum3e415c71998-03-26 20:23:01 +000057_internal_cache = {} # Used by frozen scripts only
Guido van Rossumb5114ca1992-02-19 14:50:10 +000058def checkcache(filename):
Guido van Rossumd018af31993-05-24 14:16:22 +000059 if _internal_cache.has_key(filename):
Guido van Rossum3e415c71998-03-26 20:23:01 +000060 altforms = _internal_cache[filename]
61 return _unpack_cache(altforms)
Guido van Rossumb5114ca1992-02-19 14:50:10 +000062 import marshal
63 fp, filename = _open_formfile2(filename)
64 fp.close()
65 cachename = filename + 'c'
66 try:
Guido van Rossum3e415c71998-03-26 20:23:01 +000067 fp = open(cachename, 'r')
Guido van Rossumb5114ca1992-02-19 14:50:10 +000068 except IOError:
Guido van Rossum3e415c71998-03-26 20:23:01 +000069 #print 'flp: no cache file', cachename
70 return None
Guido van Rossumb5114ca1992-02-19 14:50:10 +000071 try:
Guido van Rossum3e415c71998-03-26 20:23:01 +000072 if fp.read(4) != MAGIC:
73 print 'flp: bad magic word in cache file', cachename
74 return None
75 cache_mtime = rdlong(fp)
76 file_mtime = getmtime(filename)
77 if cache_mtime != file_mtime:
78 #print 'flp: outdated cache file', cachename
79 return None
80 #print 'flp: valid cache file', cachename
81 altforms = marshal.load(fp)
82 return _unpack_cache(altforms)
Guido van Rossumd018af31993-05-24 14:16:22 +000083 finally:
Guido van Rossum3e415c71998-03-26 20:23:01 +000084 fp.close()
Guido van Rossumd018af31993-05-24 14:16:22 +000085
86def _unpack_cache(altforms):
Tim Petersc71fe972004-07-18 06:16:08 +000087 forms = {}
88 for name in altforms.keys():
89 altobj, altlist = altforms[name]
90 obj = _newobj()
91 obj.make(altobj)
92 list = []
93 for altobj in altlist:
94 nobj = _newobj()
95 nobj.make(altobj)
96 list.append(nobj)
97 forms[name] = obj, list
98 return forms
Guido van Rossumb5114ca1992-02-19 14:50:10 +000099
100def rdlong(fp):
101 s = fp.read(4)
102 if len(s) != 4: return None
103 a, b, c, d = s[0], s[1], s[2], s[3]
104 return ord(a)<<24 | ord(b)<<16 | ord(c)<<8 | ord(d)
105
106def wrlong(fp, x):
107 a, b, c, d = (x>>24)&0xff, (x>>16)&0xff, (x>>8)&0xff, x&0xff
108 fp.write(chr(a) + chr(b) + chr(c) + chr(d))
109
110def getmtime(filename):
Guido van Rossume490d131992-03-31 19:04:48 +0000111 import os
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000112 from stat import ST_MTIME
113 try:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000114 return os.stat(filename)[ST_MTIME]
Guido van Rossume490d131992-03-31 19:04:48 +0000115 except os.error:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000116 return None
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000117
118#
119# Internal: write cached version of the form (parsing is too slow!)
120#
121def writecache(filename, forms):
122 import marshal
123 fp, filename = _open_formfile2(filename)
124 fp.close()
125 cachename = filename + 'c'
126 try:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000127 fp = open(cachename, 'w')
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000128 except IOError:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000129 print 'flp: can\'t create cache file', cachename
130 return # Never mind
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000131 fp.write('\0\0\0\0') # Seek back and write MAGIC when done
132 wrlong(fp, getmtime(filename))
Guido van Rossumd018af31993-05-24 14:16:22 +0000133 altforms = _pack_cache(forms)
134 marshal.dump(altforms, fp)
135 fp.seek(0)
136 fp.write(MAGIC)
137 fp.close()
138 #print 'flp: wrote cache file', cachename
139
140#
141# External: print some statements that set up the internal cache.
142# This is for use with the "freeze" script. You should call
143# flp.freeze(filename) for all forms used by the script, and collect
144# the output on a file in a module file named "frozenforms.py". Then
145# in the main program of the script import frozenforms.
146# (Don't forget to take this out when using the unfrozen version of
147# the script!)
148#
149def freeze(filename):
150 forms = parse_forms(filename)
151 altforms = _pack_cache(forms)
152 print 'import flp'
Walter Dörwald58217602004-02-12 17:35:32 +0000153 print 'flp._internal_cache[', repr(filename), '] =', altforms
Guido van Rossumd018af31993-05-24 14:16:22 +0000154
155#
156# Internal: create the data structure to be placed in the cache
157#
158def _pack_cache(forms):
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000159 altforms = {}
160 for name in forms.keys():
Guido van Rossum3e415c71998-03-26 20:23:01 +0000161 obj, list = forms[name]
162 altobj = obj.__dict__
163 altlist = []
164 for obj in list: altlist.append(obj.__dict__)
165 altforms[name] = altobj, altlist
Guido van Rossumd018af31993-05-24 14:16:22 +0000166 return altforms
167
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000168#
169# Internal: Locate form file (using PYTHONPATH) and open file
170#
171def _open_formfile(filename):
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000172 return _open_formfile2(filename)[0]
173
174def _open_formfile2(filename):
Fred Drake815a5232000-12-12 23:11:42 +0000175 if filename[-3:] != '.fd':
Guido van Rossum3e415c71998-03-26 20:23:01 +0000176 filename = filename + '.fd'
Guido van Rossum9ac216e1992-01-01 19:35:13 +0000177 if filename[0] == '/':
Guido van Rossum3e415c71998-03-26 20:23:01 +0000178 try:
179 fp = open(filename,'r')
180 except IOError:
181 fp = None
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000182 else:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000183 for pc in sys.path:
184 pn = os.path.join(pc, filename)
185 try:
186 fp = open(pn, 'r')
187 filename = pn
188 break
189 except IOError:
190 fp = None
Fred Drake815a5232000-12-12 23:11:42 +0000191 if fp is None:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000192 raise error, 'Cannot find forms file ' + filename
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000193 return fp, filename
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000194
195#
196# Internal: parse the fd file header, return number of forms
197#
198def _parse_fd_header(file):
199 # First read the magic header line
200 datum = _parse_1_line(file)
Fred Drake815a5232000-12-12 23:11:42 +0000201 if datum != ('Magic', 12321):
Guido van Rossum3e415c71998-03-26 20:23:01 +0000202 raise error, 'Not a forms definition file'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000203 # Now skip until we know number of forms
204 while 1:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000205 datum = _parse_1_line(file)
206 if type(datum) == type(()) and datum[0] == 'Numberofforms':
207 break
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000208 return datum[1]
209#
210# Internal: parse fd form, or skip if name doesn't match.
Jeremy Hyltonb19130b2000-06-28 14:48:01 +0000211# the special value None means 'always parse it'.
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000212#
213def _parse_fd_form(file, name):
214 datum = _parse_1_line(file)
Fred Drake815a5232000-12-12 23:11:42 +0000215 if datum != FORMLINE:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000216 raise error, 'Missing === FORM === line'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000217 form = _parse_object(file)
Fred Drake815a5232000-12-12 23:11:42 +0000218 if form.Name == name or name is None:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000219 objs = []
220 for j in range(form.Numberofobjects):
221 obj = _parse_object(file)
222 objs.append(obj)
223 return (form, objs)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000224 else:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000225 for j in range(form.Numberofobjects):
226 _skip_object(file)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000227 return None
228
229#
Jeremy Hyltonb19130b2000-06-28 14:48:01 +0000230# Internal class: a convenient place to store object info fields
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000231#
Guido van Rossum376c11a1991-12-26 13:03:39 +0000232class _newobj:
Guido van Rossumf5b61d41992-12-14 12:57:56 +0000233 def add(self, name, value):
Guido van Rossum3e415c71998-03-26 20:23:01 +0000234 self.__dict__[name] = value
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000235 def make(self, dict):
Guido van Rossum3e415c71998-03-26 20:23:01 +0000236 for name in dict.keys():
237 self.add(name, dict[name])
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000238
239#
240# Internal parsing routines.
241#
242def _parse_string(str):
Guido van Rossum0d7542e1992-03-25 14:53:05 +0000243 if '\\' in str:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000244 s = '\'' + str + '\''
245 try:
246 return eval(s)
247 except:
248 pass
Guido van Rossum28456311991-12-16 13:10:14 +0000249 return str
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000250
251def _parse_num(str):
Guido van Rossum28456311991-12-16 13:10:14 +0000252 return eval(str)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000253
254def _parse_numlist(str):
255 slist = string.split(str)
256 nlist = []
257 for i in slist:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000258 nlist.append(_parse_num(i))
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000259 return nlist
260
261# This dictionary maps item names to parsing routines.
262# If no routine is given '_parse_num' is default.
263_parse_func = { \
Guido van Rossum3e415c71998-03-26 20:23:01 +0000264 'Name': _parse_string, \
265 'Box': _parse_numlist, \
266 'Colors': _parse_numlist, \
267 'Label': _parse_string, \
268 'Name': _parse_string, \
269 'Callback': _parse_string, \
270 'Argument': _parse_string }
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000271
272# This function parses a line, and returns either
273# a string or a tuple (name,value)
274
Guido van Rossum3ccd1e61997-10-22 21:00:49 +0000275import re
276prog = re.compile('^([^:]*): *(.*)')
Guido van Rossum28456311991-12-16 13:10:14 +0000277
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000278def _parse_line(line):
Guido van Rossum3ccd1e61997-10-22 21:00:49 +0000279 match = prog.match(line)
280 if not match:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000281 return line
Guido van Rossum3ccd1e61997-10-22 21:00:49 +0000282 name, value = match.group(1, 2)
Guido van Rossum9ac216e1992-01-01 19:35:13 +0000283 if name[0] == 'N':
Tim Petersc71fe972004-07-18 06:16:08 +0000284 name = string.join(string.split(name),'')
285 name = string.lower(name)
Guido van Rossum3ccd1e61997-10-22 21:00:49 +0000286 name = string.capitalize(name)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000287 try:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000288 pf = _parse_func[name]
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000289 except KeyError:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000290 pf = _parse_num
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000291 value = pf(value)
292 return (name, value)
293
294def _readline(file):
295 line = file.readline()
Guido van Rossum28456311991-12-16 13:10:14 +0000296 if not line:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000297 raise EOFError
Guido van Rossum28456311991-12-16 13:10:14 +0000298 return line[:-1]
Tim Petersc71fe972004-07-18 06:16:08 +0000299
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000300def _parse_1_line(file):
Guido van Rossum28456311991-12-16 13:10:14 +0000301 line = _readline(file)
Guido van Rossum9ac216e1992-01-01 19:35:13 +0000302 while line == '':
Guido van Rossum3e415c71998-03-26 20:23:01 +0000303 line = _readline(file)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000304 return _parse_line(line)
305
306def _skip_object(file):
307 line = ''
308 while not line in (SPLITLINE, FORMLINE, ENDLINE):
Guido van Rossum3e415c71998-03-26 20:23:01 +0000309 pos = file.tell()
310 line = _readline(file)
Guido van Rossum9ac216e1992-01-01 19:35:13 +0000311 if line == FORMLINE:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000312 file.seek(pos)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000313
314def _parse_object(file):
Guido van Rossumb0448b61993-12-17 15:25:27 +0000315 obj = _newobj()
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000316 while 1:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000317 pos = file.tell()
318 datum = _parse_1_line(file)
319 if datum in (SPLITLINE, FORMLINE, ENDLINE):
320 if datum == FORMLINE:
321 file.seek(pos)
322 return obj
Fred Drake815a5232000-12-12 23:11:42 +0000323 if type(datum) is not type(()) or len(datum) != 2:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000324 raise error, 'Parse error, illegal line in object: '+datum
325 obj.add(datum[0], datum[1])
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000326
327#################################################################
328# Part 2 - High-level object/form creation routines #
329#################################################################
330
331#
332# External - Create a form an link to an instance variable.
333#
334def create_full_form(inst, (fdata, odatalist)):
335 form = create_form(fdata)
Guido van Rossume6c7ba81995-08-28 02:54:01 +0000336 exec 'inst.'+fdata.Name+' = form\n'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000337 for odata in odatalist:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000338 create_object_instance(inst, form, odata)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000339
340#
341# External - Merge a form into an existing form in an instance
342# variable.
343#
344def merge_full_form(inst, form, (fdata, odatalist)):
Guido van Rossume6c7ba81995-08-28 02:54:01 +0000345 exec 'inst.'+fdata.Name+' = form\n'
Fred Drake815a5232000-12-12 23:11:42 +0000346 if odatalist[0].Class != FL.BOX:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000347 raise error, 'merge_full_form() expects FL.BOX as first obj'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000348 for odata in odatalist[1:]:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000349 create_object_instance(inst, form, odata)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000350
351
352#################################################################
353# Part 3 - Low-level object/form creation routines #
354#################################################################
355
356#
357# External Create_form - Create form from parameters
358#
359def create_form(fdata):
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000360 import fl
361 return fl.make_form(FL.NO_BOX, fdata.Width, fdata.Height)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000362
363#
364# External create_object - Create an object. Make sure there are
365# no callbacks. Returns the object created.
366#
367def create_object(form, odata):
368 obj = _create_object(form, odata)
369 if odata.Callback:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000370 raise error, 'Creating free object with callback'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000371 return obj
372#
373# External create_object_instance - Create object in an instance.
374#
375def create_object_instance(inst, form, odata):
376 obj = _create_object(form, odata)
377 if odata.Callback:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000378 cbfunc = eval('inst.'+odata.Callback)
379 obj.set_call_back(cbfunc, odata.Argument)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000380 if odata.Name:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000381 exec 'inst.' + odata.Name + ' = obj\n'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000382#
383# Internal _create_object: Create the object and fill options
384#
385def _create_object(form, odata):
386 crfunc = _select_crfunc(form, odata.Class)
387 obj = crfunc(odata.Type, odata.Box[0], odata.Box[1], odata.Box[2], \
Guido van Rossum3e415c71998-03-26 20:23:01 +0000388 odata.Box[3], odata.Label)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000389 if not odata.Class in (FL.BEGIN_GROUP, FL.END_GROUP):
Guido van Rossum3e415c71998-03-26 20:23:01 +0000390 obj.boxtype = odata.Boxtype
391 obj.col1 = odata.Colors[0]
392 obj.col2 = odata.Colors[1]
393 obj.align = odata.Alignment
394 obj.lstyle = odata.Style
395 obj.lsize = odata.Size
396 obj.lcol = odata.Lcol
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000397 return obj
398#
399# Internal crfunc: helper function that returns correct create function
400#
401def _select_crfunc(fm, cl):
Guido van Rossum9ac216e1992-01-01 19:35:13 +0000402 if cl == FL.BEGIN_GROUP: return fm.bgn_group
403 elif cl == FL.END_GROUP: return fm.end_group
404 elif cl == FL.BITMAP: return fm.add_bitmap
405 elif cl == FL.BOX: return fm.add_box
406 elif cl == FL.BROWSER: return fm.add_browser
407 elif cl == FL.BUTTON: return fm.add_button
408 elif cl == FL.CHART: return fm.add_chart
409 elif cl == FL.CHOICE: return fm.add_choice
410 elif cl == FL.CLOCK: return fm.add_clock
411 elif cl == FL.COUNTER: return fm.add_counter
412 elif cl == FL.DIAL: return fm.add_dial
413 elif cl == FL.FREE: return fm.add_free
414 elif cl == FL.INPUT: return fm.add_input
415 elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton
416 elif cl == FL.MENU: return fm.add_menu
417 elif cl == FL.POSITIONER: return fm.add_positioner
418 elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton
419 elif cl == FL.SLIDER: return fm.add_slider
420 elif cl == FL.VALSLIDER: return fm.add_valslider
421 elif cl == FL.TEXT: return fm.add_text
422 elif cl == FL.TIMER: return fm.add_timer
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000423 else:
Walter Dörwald58217602004-02-12 17:35:32 +0000424 raise error, 'Unknown object type: %r' % (cl,)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000425
426
427def test():
Guido van Rossumb5114ca1992-02-19 14:50:10 +0000428 import time
Guido van Rossum31bcad21994-08-01 11:34:53 +0000429 t0 = time.time()
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000430 if len(sys.argv) == 2:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000431 forms = parse_forms(sys.argv[1])
432 t1 = time.time()
433 print 'parse time:', 0.001*(t1-t0), 'sec.'
434 keys = forms.keys()
435 keys.sort()
436 for i in keys:
437 _printform(forms[i])
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000438 elif len(sys.argv) == 3:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000439 form = parse_form(sys.argv[1], sys.argv[2])
440 t1 = time.time()
441 print 'parse time:', round(t1-t0, 3), 'sec.'
442 _printform(form)
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000443 else:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000444 print 'Usage: test fdfile [form]'
Guido van Rossumcd68a2d1991-12-11 17:29:59 +0000445
446def _printform(form):
447 f = form[0]
448 objs = form[1]
449 print 'Form ', f.Name, ', size: ', f.Width, f.Height, ' Nobj ', f.Numberofobjects
450 for i in objs:
Guido van Rossum3e415c71998-03-26 20:23:01 +0000451 print ' Obj ', i.Name, ' type ', i.Class, i.Type
452 print ' Box ', i.Box, ' btype ', i.Boxtype
453 print ' Label ', i.Label, ' size/style/col/align ', i.Size,i.Style, i.Lcol, i.Alignment
454 print ' cols ', i.Colors
455 print ' cback ', i.Callback, i.Argument