From ef5cd05c3d68137a59a84acd418342532e3940c6 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Tue, 17 Sep 1996 12:39:12 +0000 Subject: Calling Application._quit() is now preferred over raising self. --- Mac/Demo/PICTbrowse/PICTbrowse.py | 2 +- Mac/Demo/PICTbrowse/PICTbrowse2.py | 2 +- Mac/Demo/cgi.html | 7 +------ Mac/Demo/example2.html | 8 ++++---- Mac/Demo/example2/InterslipControl-2.py | 2 +- Mac/Demo/imgbrowse/imgbrowse.py | 2 +- Mac/Demo/textedit.html | 3 +-- Mac/Demo/textedit/ped.py | 2 +- Mac/Demo/waste/htmled.py | 2 +- Mac/Demo/waste/swed.py | 2 +- Mac/Demo/waste/wed.py | 2 +- 11 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Mac/Demo/PICTbrowse/PICTbrowse.py b/Mac/Demo/PICTbrowse/PICTbrowse.py index 4aabf67..412716e 100644 --- a/Mac/Demo/PICTbrowse/PICTbrowse.py +++ b/Mac/Demo/PICTbrowse/PICTbrowse.py @@ -47,7 +47,7 @@ class PICTbrowse(FrameWork.Application): self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) def quit(self, *args): - raise self + self._quit() def showPICT(self, resid): w = PICTwindow(self) diff --git a/Mac/Demo/PICTbrowse/PICTbrowse2.py b/Mac/Demo/PICTbrowse/PICTbrowse2.py index 588cc0b..c2d9c17 100644 --- a/Mac/Demo/PICTbrowse/PICTbrowse2.py +++ b/Mac/Demo/PICTbrowse/PICTbrowse2.py @@ -51,7 +51,7 @@ class PICTbrowse(FrameWork.Application): self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) def quit(self, *args): - raise self + self._quit() def showPICT(self, resid): w = PICTwindow(self) diff --git a/Mac/Demo/cgi.html b/Mac/Demo/cgi.html index 3932b28..c2369cf 100644 --- a/Mac/Demo/cgi.html +++ b/Mac/Demo/cgi.html @@ -30,11 +30,6 @@ This file contains two classes, MiniApplication and AEServer< MiniApplication is a tiny replacement for FrameWork.Application, suitable if your application does not need windows and such. -
Actually, Framework.Application has a problem for AE Servers, -due to the way it expects to be quit through an exception, and raising an exception -while inside an Apple Event handler is a very bad idea. This will be fixed. -
- AEServer is a bit of glue that does part of the appleevent decoding for you. You call installaehandler passing it the class and id (4-char strings) of the event you have a handler for and the handler callback routine. When the @@ -45,7 +40,7 @@ suites provide.

You can test AEServer by double-clicking it. It will react to the standard run/open/print/quit OSA commands. If it is running as a normal python script and you -drag a file onto the interpreter the script will tell you what event is got.

+drag a file onto the interpreter the script will tell you what event it got.

A Minimal CGI script

diff --git a/Mac/Demo/example2.html b/Mac/Demo/example2.html index aebe73d..936cfad 100644 --- a/Mac/Demo/example2.html +++ b/Mac/Demo/example2.html @@ -85,8 +85,8 @@ Next comes the definition of our main class, menu bar and the main event loop and event dispatching. In the __init__ routine we first let the base class initialize itself, then we create our modeless dialog and finally we jump into -the main loop. The main loop continues until self is -raised, which we will do when the user selects "quit". When we create +the main loop. The main loop continues until we call self._quit, +which we will do when the user selects "quit". When we create the instance of MyDialog (which inherits DialogWindow, which inherits Window) we pass a reference to the application object, this reference is used to tell @@ -97,8 +97,8 @@ clicks.

The makeusermenus() method (which is called sometime during the Application __init__ routine) creates a File menu with a Quit command (shortcut command-Q), which will callback to -our quit() method. Quit(), in turn, raises 'self' which -causes the mainloop to terminate.

+our quit() method. Quit(), in turn, calls _quit which +causes the mainloop to terminate at a convenient time.

Application provides a standard about box, but we override this by providing our own do_about() method which shows an about diff --git a/Mac/Demo/example2/InterslipControl-2.py b/Mac/Demo/example2/InterslipControl-2.py index 4945864..90d57dd 100644 --- a/Mac/Demo/example2/InterslipControl-2.py +++ b/Mac/Demo/example2/InterslipControl-2.py @@ -51,7 +51,7 @@ class InterslipControl(FrameWork.Application): self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) def quit(self, *args): - raise self + self._quit() def do_about(self, *args): f = Dlg.GetNewDialog(ID_ABOUT, -1) diff --git a/Mac/Demo/imgbrowse/imgbrowse.py b/Mac/Demo/imgbrowse/imgbrowse.py index 56d6d31..ff778bf 100644 --- a/Mac/Demo/imgbrowse/imgbrowse.py +++ b/Mac/Demo/imgbrowse/imgbrowse.py @@ -81,7 +81,7 @@ class imgbrowse(FrameWork.Application): self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit) def quit(self, *args): - raise self + self._quit() def opendoc(self, *args): fss, ok = macfs.StandardGetFile() # Any file type diff --git a/Mac/Demo/textedit.html b/Mac/Demo/textedit.html index d56ea0b..606c668 100644 --- a/Mac/Demo/textedit.html +++ b/Mac/Demo/textedit.html @@ -108,8 +108,7 @@ lines.

Oh yes: the quit callback does a little magic too. It closes all windows, and only if this succeeds it actually quits. This gives the user a chance to cancel the operation if some files are unsaved. -Quitting itself is also a bit strange: you raise self to break out of the main loop. This bit -of idiom was invented by Guido, so blame him:-).

+

Lastly, there is the idle method, called by the Application base class when no event is available. It is forwarded to the active window, so it can blink the text caret.

diff --git a/Mac/Demo/textedit/ped.py b/Mac/Demo/textedit/ped.py index 3999dae..5c2d0f6 100644 --- a/Mac/Demo/textedit/ped.py +++ b/Mac/Demo/textedit/ped.py @@ -295,7 +295,7 @@ class Ped(Application): w.close() if self._windows: return - raise self + self._quit() # # Edit menu diff --git a/Mac/Demo/waste/htmled.py b/Mac/Demo/waste/htmled.py index 15b9035..e56b607 100644 --- a/Mac/Demo/waste/htmled.py +++ b/Mac/Demo/waste/htmled.py @@ -730,7 +730,7 @@ class Wed(Application): w.close() if self._windows: return - raise self + self._quit() # # Edit menu diff --git a/Mac/Demo/waste/swed.py b/Mac/Demo/waste/swed.py index dc5de6a..8107434 100644 --- a/Mac/Demo/waste/swed.py +++ b/Mac/Demo/waste/swed.py @@ -558,7 +558,7 @@ class Wed(Application): w.close() if self._windows: return - raise self + self._quit() # # Edit menu diff --git a/Mac/Demo/waste/wed.py b/Mac/Demo/waste/wed.py index d4f08f4..6ddb79b 100644 --- a/Mac/Demo/waste/wed.py +++ b/Mac/Demo/waste/wed.py @@ -368,7 +368,7 @@ class Wed(Application): w.close() if self._windows: return - raise self + self._quit() # # Edit menu -- cgit v0.12