annotate Mac/Demo/example2.html @ 11518:cc412dfd79f7 legacy-trunk

New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip module.
author Jack Jansen <jack.jansen@cwi.nl>
date Fri, 03 Dec 1999 15:15:28 +0000
parents 149a54798896
children 16fc717bea3c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 <HTML><HEAD><TITLE>Using python to create Macintosh applications, part two</TITLE></HEAD>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2 <BODY>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 <H1>Using python to create Macintosh applications, part two</H1>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 <HR>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 In this document we rewrite the application of the <A
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7 HREF="example1.html">previous example</A> to use modeless dialogs. We
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8 will use an application framework, and we will have a look at creating
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
9 applets, standalone applications written in Python. The <A
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
10 HREF="example2/dnslookup-2.py">source code</A> and
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
11 <A HREF="example2/dnslookup-2.rsrc">resource file</A> are available in the folder
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
12 <A HREF="example2">example2</A>. <p>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 Again, we start with ResEdit to create our dialogs. Not only do we
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
15 want a main dialog this time but also an "About" dialog. This example is less
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
16 than complete since we do not provide a <A NAME="bundle">BNDL resource</A>
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
17 and related stuff that an application cannot be without. We are able to do this
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
18 when building a python applet since BuildApplet will substitute default resources
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
19 for BNDL, etc. when none are supplied (<A HREF="#no-bundle">See below</A>.)
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
20 "Inside Mac" or various
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
21 books on Macintosh programming will help here. Also, you can refer to
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 the resource files provided in the Python source distribution for some
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23 of the python-specific points of BNDL programming: the
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24 "appletbundle.rsrc" file is what is used for creating applets if you
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 don't provide your own resource file. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
27 When creating your own BNDL resouorces, keep in mind that the Finder gets
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
28 confused if you have more than one application with the same signature. This may be due
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
29 to some incorrectness on the side of "BuildApplet", I am not sure. There is one
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
30 case when you definitely need a unique signature: when you create an applet that
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
31 has its own data files and you want the user to be able to start your
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
32 applet by double-clicking one of the datafiles. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
34 Let's have a look at dnslookup-2.rsrc, our resource file. Dialog 512 is the
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
35 main window which has one button (Lookup), two labels and
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
36 two text entry areas, one of which is used for output only. The "Quit" and
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
37 button has disappeared, because its function is handled by a menu choice. Here's
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
38 what it will look like at run time:<p>
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
39 <div align=center>
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
40 <img width=324 height=205 src="example2/dnslookup-2.gif" alt="dialog image">
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
41 </div>
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
42 <p>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
43
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
44 <H2>A modeless dialog application using FrameWork</H2>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
45
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
46 On to the source code in <A
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
47 HREF="example2/dnslookup-2.py">dnslookup-2.py</A>. The
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
48 start is similar to our previous example program <A
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
49 HREF="example1/dnslookup-1.py">dnslookup-1.py</A>, with
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
50 one extra module being imported. To make life more simple we will use
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
51 the <CODE>FrameWork</CODE> module, a nifty piece of code that handles
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
52 all the gory Mac details of event loop programming, menubar
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
53 installation and all the other code that is the same for every Mac
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
54 program in the world. Like most standard modules, FrameWork will run
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
55 some sample test code when you invoke it as a main program, so try it
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
56 now. It will create a menu bar with an Apple menu with the about box
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
57 and a "File" menu with some pythonesque choices (which do nothing
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
58 interesting, by the way) and a "Quit" command that works. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
59
3531
38e1480e7f89 Added documentation on FrameWork, TextEdit and Waste
Jack Jansen <jack.jansen@cwi.nl>
parents: 3457
diff changeset
60 <BLOCKQUOTE>
38e1480e7f89 Added documentation on FrameWork, TextEdit and Waste
Jack Jansen <jack.jansen@cwi.nl>
parents: 3457
diff changeset
61 If you have not used <code>FrameWork</code> before you may want to
38e1480e7f89 Added documentation on FrameWork, TextEdit and Waste
Jack Jansen <jack.jansen@cwi.nl>
parents: 3457
diff changeset
62 first take a look at the <A HREF="textedit.html">Pathetic EDitor</A>
38e1480e7f89 Added documentation on FrameWork, TextEdit and Waste
Jack Jansen <jack.jansen@cwi.nl>
parents: 3457
diff changeset
63 example, which builds a minimal text editor using FrameWork and TextEdit.
38e1480e7f89 Added documentation on FrameWork, TextEdit and Waste
Jack Jansen <jack.jansen@cwi.nl>
parents: 3457
diff changeset
64 On the other hand: we don't use many features of FrameWork, so you could
38e1480e7f89 Added documentation on FrameWork, TextEdit and Waste
Jack Jansen <jack.jansen@cwi.nl>
parents: 3457
diff changeset
65 also continue with this document.
38e1480e7f89 Added documentation on FrameWork, TextEdit and Waste
Jack Jansen <jack.jansen@cwi.nl>
parents: 3457
diff changeset
66 </BLOCKQUOTE>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
67
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
68 After the imports we get the definitions of resource-IDs in our
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
69 resource file, slightly changed from the previous version of our
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
70 program. The main program is also
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
71 similar to our previous version, with one important exception: we
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
72 first check to see whether our resource is available before opening
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
73 the resource file. Why is this? Because later, when we will have
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
74 converted the script to an applet, our resources will be available in
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
75 the applet file and we don't need the separate resource file
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
76 anymore. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
77
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
78 Next comes the definition of our main class,
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
79 <CODE>DNSLookup</CODE>, which inherits
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
80 <CODE>FrameWork.Application</CODE>. The Application class handles the
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
81 menu bar and the main event loop and event dispatching. In the
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
82 <CODE>__init__</CODE> routine we first let the base class initialize
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
83 itself, then we create our modeless dialog and finally we jump into
4314
3b3870b9acf2 Calling Application._quit() is now preferred over raising self.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3531
diff changeset
84 the main loop. The main loop continues until we call <CODE>self._quit</CODE>,
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
85 which we will do when the user selects "Quit". When we create
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
86 the instance of <CODE>MyDialog</CODE> (which inherits
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
87 <CODE>DialogWindow</CODE>, which inherits <CODE>Window</CODE>) we pass
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
88 a reference to the application object, this reference is used to tell
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
89 Application about our new window. This enables the event loop to keep
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
90 track of all windows and dispatch things like update events and mouse
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
91 clicks. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
92
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
93 The <CODE>makeusermenus()</CODE> method (which is called sometime
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
94 during the Application <CODE>__init__</CODE> routine) creates a File
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
95 menu with a Quit command (shortcut command-Q), which will callback to
4314
3b3870b9acf2 Calling Application._quit() is now preferred over raising self.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3531
diff changeset
96 our quit() method. <CODE>Quit()</CODE>, in turn, calls <CODE>_quit</CODE> which
3b3870b9acf2 Calling Application._quit() is now preferred over raising self.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3531
diff changeset
97 causes the mainloop to terminate at a convenient time. <p>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
98
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
99 Application provides a standard about box, but we override this by
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
100 providing our own <CODE>do_about()</CODE> method which shows an about
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
101 box from a resource as a modal dialog. This piece of code should look
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
102 familiar to you from the previous example program. That do_about is
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
103 called when the user selects About from the Apple menu is, again,
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
104 taken care of by the __init__ routine of Application. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
105
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
106 The <CODE>MyDialog</CODE> class is the container for our main
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
107 window. Initialization is again done by first calling the base class
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
108 <CODE>__init__</CODE> function and finally setting the local variable
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
109 "parent." <p>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
110
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
111 <CODE>Do_itemhit()</CODE> is called when an item is selected in this
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
112 dialog by the user. We are passed the item number (and the original
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
113 event structure, which we normally ignore). The code is similar to the
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
114 main loop of our previous example program: a switch depending on the
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
115 item selected. <CODE>Dnslookup()</CODE> is quite similar to our previous
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
116 example. <p>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
117
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
118 <H2><IMG SRC="html.icons/mkapplet.gif"><A NAME="applets">Creating applets</A></H2>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
119
6171
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
120 Now let us try to turn the python script into an applet, a standalone
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
121 application. This will <em>not</em> work if you have the "classic 68k"
7468
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
122 Python distribution, only if you have the cfm68k or PPC distribution.
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
123
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
124 <blockquote>
6171
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
125 Actually, "standalone" is probably not the correct term here, since an
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
126 applet does still depend on a lot of the python environment: the
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
127 PythonCore shared library, the Python Preferences file, the python Lib
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
128 folder and any other modules that the main module depends on. It is
7468
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
129 possible to get rid of all these dependencies and create true standalone
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
130 applications in Python, but this is a bit difficult. See <a href="standalone.html">
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
131 Standalone Applications in Python</a> for details. For this
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
132 document, by standalone we mean here that
6171
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
133 the script has the look-and-feel of an application, including the
7468
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
134 ability to have its own document types, be droppable, etc.
149a54798896 Added (minimal) documentation on how to build standalone applications
Jack Jansen <jack.jansen@cwi.nl>
parents: 6171
diff changeset
135 </blockquote>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
136
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
137 The easiest way to create an applet is to take your source file and
6171
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
138 drop it onto "BuildApplet", located in the Python home
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
139 folder. This will create an applet with the same name as your python
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
140 source with the ".py" stripped. Also, if a resource file with the same
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
141 name as your source but with ".rsrc" extension is available the
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
142 resources from that file will be copied to your applet too. If there
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
143 is no resource file for your script a set of default resources will be
6171
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
144 used, and the applet will have the default creator 'Pyt0'. The latter
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
145 also happens if you do have a resource file but without the BNDL
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
146 combo. <A NAME="no-bundle">Actually</A>, as in the present example.
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
147 <p>
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
148
6171
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
149 If you need slightly more control over the BuildApplet process you can
9a3e6f0d6b5a Modified for installer and new names of various applets. Also cleaned
Jack Jansen <jack.jansen@cwi.nl>
parents: 4314
diff changeset
150 double-click it, and you will get dialogs for source and
3457
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
151 destination of the applet. The rest of the process, including locating
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
152 the resource file, remains the same. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
153
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
154 Note that though our example application completely bypasses the
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
155 normal python user interface this is by no means necessary. Any python
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
156 script can be turned into an applet, and all the usual features of the
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
157 interpreter still work. <p>
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
158
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
159 That's all for this example, you may now return to the <A HREF="index.html">
a71d2fd90fa8 Explanations of the examples here
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
160 table of contents</A> to pick another topic. <p>
11518
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
161 </BODY>
cc412dfd79f7 New examples by Tony Ingraldi, using dns-lookup in stead of the funny interslip
Jack Jansen <jack.jansen@cwi.nl>
parents: 7468
diff changeset
162 </HTML>