| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="mac.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="mac.html" title='Macintosh Library Modules' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-autoGIL.html" /> |
| 13 | <link rel="prev" href="module-EasyDialogs.html" /> |
| 14 | <link rel="parent" href="macpython-modules.html" /> |
| 15 | <link rel="next" href="application-objects.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>2.8 FrameWork -- Interactive application framework</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="2.7.1 ProgressBar Objects" |
| 25 | href="progressbar-objects.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="2. MacPython Modules" |
| 28 | href="macpython-modules.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="2.8.1 Application Objects" |
| 31 | href="application-objects.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Macintosh Library Modules</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="progressbar-objects.html">2.7.1 ProgressBar Objects</A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="macpython-modules.html">2. MacPython Modules</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="application-objects.html">2.8.1 Application Objects</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION004800000000000000000"> |
| 56 | 2.8 <tt class="module">FrameWork</tt> -- |
| 57 | Interactive application framework</A> |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | <A NAME="module-FrameWork"></A> |
| 62 | <p class="availability">Availability: <span |
| 63 | class="platform">Macintosh</span>.</p> |
| 64 | |
| 65 | <P> |
| 66 | The <tt class="module">FrameWork</tt> module contains classes that together provide a |
| 67 | framework for an interactive Macintosh application. The programmer |
| 68 | builds an application by creating subclasses that override various |
| 69 | methods of the bases classes, thereby implementing the functionality |
| 70 | wanted. Overriding functionality can often be done on various |
| 71 | different levels, i.e. to handle clicks in a single dialog window in a |
| 72 | non-standard way it is not necessary to override the complete event |
| 73 | handling. |
| 74 | |
| 75 | <P> |
| 76 | Work on the <tt class="module">FrameWork</tt> has pretty much stopped, now that |
| 77 | <tt class="module">PyObjC</tt> is available for full Cocoa access from Python, and the |
| 78 | documentation describes only the most important functionality, and not |
| 79 | in the most logical manner at that. Examine the source or the examples |
| 80 | for more details. The following are some comments posted on the |
| 81 | MacPython newsgroup about the strengths and limitations of |
| 82 | <tt class="module">FrameWork</tt>: |
| 83 | |
| 84 | <P> |
| 85 | <BLOCKQUOTE> |
| 86 | The strong point of <tt class="module">FrameWork</tt> is that it allows you to break |
| 87 | into the control-flow at many different places. <tt class="module"><a href="module-W.html">W</a></tt>, for |
| 88 | instance, uses a different way to enable/disable menus and that plugs |
| 89 | right in leaving the rest intact. The weak points of |
| 90 | <tt class="module">FrameWork</tt> are that it has no abstract command interface (but |
| 91 | that shouldn't be difficult), that it's dialog support is minimal and |
| 92 | that it's control/toolbar support is non-existent. |
| 93 | |
| 94 | </BLOCKQUOTE> |
| 95 | |
| 96 | <P> |
| 97 | The <tt class="module">FrameWork</tt> module defines the following functions: |
| 98 | |
| 99 | <P> |
| 100 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 101 | <td><nobr><b><tt id='l2h-98' xml:id='l2h-98' class="function">Application</tt></b>(</nobr></td> |
| 102 | <td><var></var>)</td></tr></table></dt> |
| 103 | <dd> |
| 104 | An object representing the complete application. See below for a |
| 105 | description of the methods. The default <tt class="method">__init__()</tt> routine |
| 106 | creates an empty window dictionary and a menu bar with an apple menu. |
| 107 | </dl> |
| 108 | |
| 109 | <P> |
| 110 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 111 | <td><nobr><b><tt id='l2h-99' xml:id='l2h-99' class="function">MenuBar</tt></b>(</nobr></td> |
| 112 | <td><var></var>)</td></tr></table></dt> |
| 113 | <dd> |
| 114 | An object representing the menubar. This object is usually not created |
| 115 | by the user. |
| 116 | </dl> |
| 117 | |
| 118 | <P> |
| 119 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 120 | <td><nobr><b><tt id='l2h-100' xml:id='l2h-100' class="function">Menu</tt></b>(</nobr></td> |
| 121 | <td><var>bar, title</var><big>[</big><var>, after</var><big>]</big><var></var>)</td></tr></table></dt> |
| 122 | <dd> |
| 123 | An object representing a menu. Upon creation you pass the |
| 124 | <code>MenuBar</code> the menu appears in, the <var>title</var> string and a |
| 125 | position (1-based) <var>after</var> where the menu should appear (default: |
| 126 | at the end). |
| 127 | </dl> |
| 128 | |
| 129 | <P> |
| 130 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 131 | <td><nobr><b><tt id='l2h-101' xml:id='l2h-101' class="function">MenuItem</tt></b>(</nobr></td> |
| 132 | <td><var>menu, title</var><big>[</big><var>, shortcut, callback</var><big>]</big><var></var>)</td></tr></table></dt> |
| 133 | <dd> |
| 134 | Create a menu item object. The arguments are the menu to create, the |
| 135 | item title string and optionally the keyboard shortcut |
| 136 | and a callback routine. The callback is called with the arguments |
| 137 | menu-id, item number within menu (1-based), current front window and |
| 138 | the event record. |
| 139 | |
| 140 | <P> |
| 141 | Instead of a callable object the callback can also be a string. In |
| 142 | this case menu selection causes the lookup of a method in the topmost |
| 143 | window and the application. The method name is the callback string |
| 144 | with <code>'domenu_'</code> prepended. |
| 145 | |
| 146 | <P> |
| 147 | Calling the <code>MenuBar</code> <tt class="method">fixmenudimstate()</tt> method sets the |
| 148 | correct dimming for all menu items based on the current front window. |
| 149 | </dl> |
| 150 | |
| 151 | <P> |
| 152 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 153 | <td><nobr><b><tt id='l2h-102' xml:id='l2h-102' class="function">Separator</tt></b>(</nobr></td> |
| 154 | <td><var>menu</var>)</td></tr></table></dt> |
| 155 | <dd> |
| 156 | Add a separator to the end of a menu. |
| 157 | </dl> |
| 158 | |
| 159 | <P> |
| 160 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 161 | <td><nobr><b><tt id='l2h-103' xml:id='l2h-103' class="function">SubMenu</tt></b>(</nobr></td> |
| 162 | <td><var>menu, label</var>)</td></tr></table></dt> |
| 163 | <dd> |
| 164 | Create a submenu named <var>label</var> under menu <var>menu</var>. The menu |
| 165 | object is returned. |
| 166 | </dl> |
| 167 | |
| 168 | <P> |
| 169 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 170 | <td><nobr><b><tt id='l2h-104' xml:id='l2h-104' class="function">Window</tt></b>(</nobr></td> |
| 171 | <td><var>parent</var>)</td></tr></table></dt> |
| 172 | <dd> |
| 173 | Creates a (modeless) window. <var>Parent</var> is the application object to |
| 174 | which the window belongs. The window is not displayed until later. |
| 175 | </dl> |
| 176 | |
| 177 | <P> |
| 178 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 179 | <td><nobr><b><tt id='l2h-105' xml:id='l2h-105' class="function">DialogWindow</tt></b>(</nobr></td> |
| 180 | <td><var>parent</var>)</td></tr></table></dt> |
| 181 | <dd> |
| 182 | Creates a modeless dialog window. |
| 183 | </dl> |
| 184 | |
| 185 | <P> |
| 186 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 187 | <td><nobr><b><tt id='l2h-106' xml:id='l2h-106' class="function">windowbounds</tt></b>(</nobr></td> |
| 188 | <td><var>width, height</var>)</td></tr></table></dt> |
| 189 | <dd> |
| 190 | Return a <code>(<var>left</var>, <var>top</var>, <var>right</var>, <var>bottom</var>)</code> |
| 191 | tuple suitable for creation of a window of given width and height. The |
| 192 | window will be staggered with respect to previous windows, and an |
| 193 | attempt is made to keep the whole window on-screen. However, the window will |
| 194 | however always be the exact size given, so parts may be offscreen. |
| 195 | </dl> |
| 196 | |
| 197 | <P> |
| 198 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 199 | <td><nobr><b><tt id='l2h-107' xml:id='l2h-107' class="function">setwatchcursor</tt></b>(</nobr></td> |
| 200 | <td><var></var>)</td></tr></table></dt> |
| 201 | <dd> |
| 202 | Set the mouse cursor to a watch. |
| 203 | </dl> |
| 204 | |
| 205 | <P> |
| 206 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 207 | <td><nobr><b><tt id='l2h-108' xml:id='l2h-108' class="function">setarrowcursor</tt></b>(</nobr></td> |
| 208 | <td><var></var>)</td></tr></table></dt> |
| 209 | <dd> |
| 210 | Set the mouse cursor to an arrow. |
| 211 | </dl> |
| 212 | |
| 213 | <P> |
| 214 | |
| 215 | <p><br /></p><hr class='online-navigation' /> |
| 216 | <div class='online-navigation'> |
| 217 | <!--Table of Child-Links--> |
| 218 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> |
| 219 | |
| 220 | <UL CLASS="ChildLinks"> |
| 221 | <LI><A href="application-objects.html">2.8.1 Application Objects</a> |
| 222 | <LI><A href="window-objects.html">2.8.2 Window Objects</a> |
| 223 | <LI><A href="controlswindow-object.html">2.8.3 ControlsWindow Object</a> |
| 224 | <LI><A href="scrolledwindow-object.html">2.8.4 ScrolledWindow Object</a> |
| 225 | <LI><A href="dialogwindow-objects.html">2.8.5 DialogWindow Objects</a> |
| 226 | </ul> |
| 227 | <!--End of Table of Child-Links--> |
| 228 | </div> |
| 229 | |
| 230 | <DIV CLASS="navigation"> |
| 231 | <div class='online-navigation'> |
| 232 | <p></p><hr /> |
| 233 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 234 | <tr> |
| 235 | <td class='online-navigation'><a rel="prev" title="2.7.1 ProgressBar Objects" |
| 236 | href="progressbar-objects.html"><img src='../icons/previous.png' |
| 237 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 238 | <td class='online-navigation'><a rel="parent" title="2. MacPython Modules" |
| 239 | href="macpython-modules.html"><img src='../icons/up.png' |
| 240 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 241 | <td class='online-navigation'><a rel="next" title="2.8.1 Application Objects" |
| 242 | href="application-objects.html"><img src='../icons/next.png' |
| 243 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 244 | <td align="center" width="100%">Macintosh Library Modules</td> |
| 245 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 246 | href="contents.html"><img src='../icons/contents.png' |
| 247 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 248 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 249 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 250 | <td class='online-navigation'><a rel="index" title="Index" |
| 251 | href="genindex.html"><img src='../icons/index.png' |
| 252 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 253 | </tr></table> |
| 254 | <div class='online-navigation'> |
| 255 | <b class="navlabel">Previous:</b> |
| 256 | <a class="sectref" rel="prev" href="progressbar-objects.html">2.7.1 ProgressBar Objects</A> |
| 257 | <b class="navlabel">Up:</b> |
| 258 | <a class="sectref" rel="parent" href="macpython-modules.html">2. MacPython Modules</A> |
| 259 | <b class="navlabel">Next:</b> |
| 260 | <a class="sectref" rel="next" href="application-objects.html">2.8.1 Application Objects</A> |
| 261 | </div> |
| 262 | </div> |
| 263 | <hr /> |
| 264 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 265 | </DIV> |
| 266 | <!--End of Navigation Panel--> |
| 267 | <ADDRESS> |
| 268 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 269 | </ADDRESS> |
| 270 | </BODY> |
| 271 | </HTML> |