From a4adacbd7e605fa8e81181379aba3f7063c3dcc8 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Mon, 21 Jan 2002 23:01:24 +0000 Subject: [PATCH] Changes by Donovan Preston (and a few minor ones by me) to make IDE run under MachoPython. Mainly making sure we don't call routines that don't exist. --- Mac/Lib/FrameWork.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/Mac/Lib/FrameWork.py b/Mac/Lib/FrameWork.py index f383609858e..82017f16dc2 100644 --- a/Mac/Lib/FrameWork.py +++ b/Mac/Lib/FrameWork.py @@ -153,7 +153,8 @@ class Application: def mainloop(self, mask = everyEvent, wait = None): self.quitting = 0 - saveparams = apply(MacOS.SchedParams, self.schedparams) + if hasattr(MacOS, 'SchedParams'): + saveparams = apply(MacOS.SchedParams, self.schedparams) try: while not self.quitting: try: @@ -164,7 +165,8 @@ class Application: # applications. break finally: - apply(MacOS.SchedParams, saveparams) + if hasattr(MacOS, 'SchedParams'): + apply(MacOS.SchedParams, saveparams) def dopendingevents(self, mask = everyEvent): """dopendingevents - Handle all pending events""" @@ -214,6 +216,8 @@ class Application: def asyncevents(self, onoff): """asyncevents - Set asynchronous event handling on or off""" + if MacOS.runtimemodel == 'macho': + raise 'Unsupported in MachoPython' old = self._doing_asyncevents if old: MacOS.SetEventHandler() @@ -257,7 +261,8 @@ class Application: except AttributeError: # Not menubar or something, so assume someone # else's window - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) return elif self._windows.has_key(wid): # It is a window. Hand off to correct window. @@ -272,14 +277,17 @@ class Application: handler(partcode, wid, event) def do_inSysWindow(self, partcode, window, event): - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) def do_inDesk(self, partcode, window, event): - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) def do_inMenuBar(self, partcode, window, event): if not self.menubar: - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) return (what, message, when, where, modifiers) = event result = MenuSelect(where) @@ -294,7 +302,8 @@ class Application: HiliteMenu(0) def do_menu(self, id, item, window, event): - MacOS.OutputSeen() + if hasattr(MacOS, 'OutputSeen'): + MacOS.OutputSeen() self.menubar.dispatch(id, item, window, event) @@ -303,11 +312,13 @@ class Application: if DEBUG: print "Mouse down at global:", where if DEBUG: print "\tUnknown part code:", partcode if DEBUG: print "\tEvent:", self.printevent(event) - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) def do_unknownwindow(self, partcode, window, event): if DEBUG: print 'Unknown window:', window - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) def do_keyDown(self, event): self.do_key(event) @@ -332,7 +343,8 @@ class Application: raise self else: if not self.menubar: - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) return else: # See whether the front window wants it @@ -356,7 +368,8 @@ class Application: window = self._windows[wid] window.do_rawupdate(wid, event) else: - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) def do_activateEvt(self, event): (what, message, when, where, modifiers) = event @@ -365,7 +378,8 @@ class Application: window = self._windows[wid] window.do_activate(modifiers & 1, event) else: - MacOS.HandleEvent(event) + if hasattr(MacOS, 'HandleEvent'): + MacOS.HandleEvent(event) def do_osEvt(self, event): (what, message, when, where, modifiers) = event