1 """Create an applet from a Python script.
3 This puts up a dialog asking for a Python source file ('TEXT').
4 The output is a file with the same name but its ".py" suffix dropped.
5 It is created by copying an applet template and then adding a 'PYC '
6 resource named __main__ containing the compiled, marshalled script.
11 sys
.stdout
= sys
.stderr
23 except buildtools
.BuildError
, detail
:
24 EasyDialogs
.Message(detail
)
31 # (there's no point in proceeding if we can't find it)
33 template
= buildtools
.findtemplate()
35 # Ask for source text if not specified in sys.argv[1:]
38 srcfss
, ok
= macfs
.PromptGetFile('Select Python source or applet:', 'TEXT', 'APPL')
41 filename
= srcfss
.as_pathname()
42 tp
, tf
= os
.path
.split(filename
)
47 dstfss
, ok
= macfs
.StandardPutFile('Save application as:', tf
)
49 dstfilename
= dstfss
.as_pathname()
50 cr
, tp
= MacOS
.GetCreatorAndType(filename
)
52 buildtools
.update(template
, filename
, dstfilename
)
54 buildtools
.process(template
, filename
, dstfilename
, 1)
57 # Loop over all files to be processed
58 for filename
in sys
.argv
[1:]:
59 cr
, tp
= MacOS
.GetCreatorAndType(filename
)
61 buildtools
.update(template
, filename
, '')
63 buildtools
.process(template
, filename
, '', 1)
66 if __name__
== '__main__':