from Carbon import Events
import traceback
from types import *
-
from Carbon import Menu; MenuToolbox = Menu; del Menu
+if hasattr(Win, "FrontNonFloatingWindow"):
+ MyFrontWindow = Win.FrontNonFloatingWindow
+else:
+ MyFrontWindow = Win.FrontWindow
+
+
KILLUNKNOWNWINDOWS = 0 # Set to 0 for debugging.
class Application(FrameWork.Application):
def mainloop(self, mask=FrameWork.everyEvent, wait=None):
import W
self.quitting = 0
- saveyield = MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ saveyield = MacOS.EnableAppswitch(-1)
try:
while not self.quitting:
try:
self.do1event(mask, wait)
except W.AlertError, detail:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
W.Message(detail)
except self.DebuggerQuit:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
except:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
import PyEdit
PyEdit.tracebackwindow.traceback()
finally:
- MacOS.EnableAppswitch(1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(1)
def debugger_mainloop(self, mask=FrameWork.everyEvent, wait=None):
import W
self.debugger_quitting = 0
- saveyield = MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ saveyield = MacOS.EnableAppswitch(-1)
try:
while not self.quitting and not self.debugger_quitting:
try:
import PyEdit
PyEdit.tracebackwindow.traceback()
finally:
- MacOS.EnableAppswitch(saveyield)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(saveyield)
def breathe(self, wait=1):
import W
break
def do_frontWindowMethod(self, attr, *args):
- wid = Win.FrontWindow()
+ wid = MyFrontWindow()
if wid and self._windows.has_key(wid):
window = self._windows[wid]
if hasattr(window, attr):
if keycode in self.fkeymaps.keys(): # JJS
ch = self.fkeymaps[keycode]
modifiers = modifiers | FrameWork.cmdKey
- wid = Win.FrontWindow()
+ wid = MyFrontWindow()
if modifiers & FrameWork.cmdKey and not modifiers & FrameWork.shiftKey:
if wid and self._windows.has_key(wid):
self.checkmenus(self._windows[wid])
Qd.InitCursor()
(what, message, when, where, modifiers) = event
self.checkopenwindowsmenu()
- wid = Win.FrontWindow()
+ wid = MyFrontWindow()
if wid and self._windows.has_key(wid):
self.checkmenus(self._windows[wid])
else:
def checkopenwindowsmenu(self):
if self._openwindowscheckmark:
self.openwindowsmenu.menu.CheckMenuItem(self._openwindowscheckmark, 0)
- window = Win.FrontWindow()
+ window = MyFrontWindow()
if window:
for item, wid in self._openwindows.items():
if wid == window:
# exec in that window's namespace.
# xxx what to do when it's not saved???
# promt to save?
- MacOS.EnableAppswitch(0)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(0)
execfile(path, {'__name__': '__main__', '__file__': path})
except W.AlertError, detail:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
raise W.AlertError, detail
except KeyboardInterrupt:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
except:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
import PyEdit
PyEdit.tracebackwindow.traceback(1)
else:
- MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(-1)
#os.chdir(cwd)
def openscript(self, filename, lineno=None, charoffset=0, modname=""):
def _getmenuhandler(self, callback):
menuhandler = None
- wid = Win.FrontWindow()
+ wid = MyFrontWindow()
if wid and self.bar.parent._windows.has_key(wid):
window = self.bar.parent._windows[wid]
if hasattr(window, "domenu_" + callback):
import traceback
from types import InstanceType, StringType
+if hasattr(Win, "FrontNonFloatingWindow"):
+ MyFrontWindow = Win.FrontNonFloatingWindow
+else:
+ MyFrontWindow = Win.FrontWindow
+
class Window(FrameWork.Window, Wbase.SelectableWidget):
Dialog.close(self)
def mainloop(self):
- saveyield = MacOS.EnableAppswitch(-1)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ saveyield = MacOS.EnableAppswitch(-1)
while not self.done:
#self.do1event()
self.do1event( Events.keyDownMask +
Events.mDownMask +
Events.mUpMask,
10)
- MacOS.EnableAppswitch(saveyield)
+ if hasattr(MacOS, 'EnableAppswitch'):
+ MacOS.EnableAppswitch(saveyield)
def do1event(self, mask = Events.everyEvent, wait = 0):
ok, event = self.app.getevent(mask, wait)
def do_key(self, event):
(what, message, when, where, modifiers) = event
- w = Win.FrontWindow()
- if w <> self.wid:
- return
+ #w = Win.FrontWindow()
+ #if w <> self.wid:
+ # return
c = chr(message & Events.charCodeMask)
if modifiers & Events.cmdKey:
self.app.checkmenus(self)
raise TypeError, 'string expected'
import W
app = W.getapplication()
- wid = Win.FrontWindow()
+ wid = MyFrontWindow()
if wid and app._windows.has_key(wid):
window = app._windows[wid]
if hasattr(window, "insert"):
"Can't find window or widget to insert text into; copy to clipboard instead?",
1) == 1:
from Carbon import Scrap
- Scrap.ZeroScrap()
- Scrap.PutScrap('TEXT', stuff)
+ if hasattr(Scrap, 'PutScrap'):
+ Scrap.ZeroScrap()
+ Scrap.PutScrap('TEXT', stuff)
+ else:
+ Scrap.ClearCurrentScrap()
+ sc = Scrap.GetCurrentScrap()
+ sc.PutScrapFlavor('TEXT', 0, stuff)
# not quite based on the same function in FrameWork