def _update(self, value): maxval = self.maxval if maxval == 0: Ctl.IdleControls(self.w) else: if maxval > 32767: value = int(value / (maxval / 32767.0)) maxval = 32767 maxval = int(maxval) value = int(value) progbar = self.d.GetDialogItemAsControl(3) progbar.SetControlMaximum(maxval) progbar.SetControlValue(value) ready, ev = Evt.WaitNextEvent(Events.mDownMask, 1) if ready: what, msg, when, where, mod = ev part = Win.FindWindow(where)[0] if Dlg.IsDialogEvent(ev): ds = Dlg.DialogSelect(ev) if ds[0] and ds[1] == self.d and ds[-1] == 1: self.w.HideWindow() self.w = None self.d = None raise KeyboardInterrupt, ev elif part == 4: self.w.DragWindow(where, screenbounds) else: MacOS.HandleEvent(ev) return
def __ensure_WMAvailable(klass): if klass.__eventloop_initialized: return 1 if not MacOS.WMAvailable(): return 0 Evt.WaitNextEvent(0, 0) return 1
def __ensure_WMAvailable(klass): if klass.__eventloop_initialized: return 1 if not MacOS.WMAvailable(): return 0 # Workaround for a but in MacOSX 10.2: we must have an event # loop before we can call AESend. Evt.WaitNextEvent(0,0) return 1
def wait(): from Carbon import Evt from Carbon import Events global splash try: splash except NameError: return Qd.InitCursor() time = Evt.TickCount() whattext = 0 drawtext(whattext) while _keepsplashscreenopen: ok, event = Evt.EventAvail(Events.highLevelEventMask) if ok: # got apple event, back to mainloop break ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask) if ok: ok, event = Evt.WaitNextEvent( Events.mDownMask | Events.keyDownMask | Events.updateMask, 30) if ok: (what, message, when, where, modifiers) = event if what == Events.updateEvt: if Win.WhichWindow(message) == splash: UpdateSplash(1, whattext) else: break if Evt.TickCount() - time > 360: whattext = not whattext drawtext(whattext) time = Evt.TickCount() del splash
def _dooneevent(self, mask=highLevelEventMask, timeout=60): got, event = Evt.WaitNextEvent(mask, timeout) if got: self._lowlevelhandler(event)
self.SetPort() l, t, r, b = self._bounds bounds = l, t, r, b = l + 1, t + 1, r - 16, b - 1 abscol = l + self.col mincol = l + self.mincol maxcol = r - 10 diff = abscol - x Qd.PenPat('\000\377\000\377\000\377\000\377') Qd.PenMode(QuickDraw.srcXor) rect = abscol - 1, t, abscol, b Qd.PaintRect(rect) lastpoint = (x, y) newcol = -1 #W.SetCursor('fist') while Evt.Button(): Evt.WaitNextEvent(0, 1, None) # needed for OSX (x, y) = Evt.GetMouse() if (x, y) <> lastpoint: newcol = x + diff newcol = max(newcol, mincol) newcol = min(newcol, maxcol) Qd.PaintRect(rect) rect = newcol - 1, t, newcol, b Qd.PaintRect(rect) lastpoint = (x, y) Qd.PaintRect(rect) Qd.PenPat(Qd.GetQDGlobalsBlack()) Qd.PenNormal() if newcol > 0 and newcol <> abscol: self.setcolumn(newcol - l)
def dooneevent(self, mask=everyEvent, timeout=3600): got, event = Evt.WaitNextEvent(mask, timeout) if got: self.lowlevelhandler(event)
"""MiniAEFrame - A minimal AppleEvent Application framework.
def main(): print 'hello world' # XXXX # skip the toolbox initializations, already done # XXXX Should use gestalt here to check for quicktime version Qt.EnterMovies() # Get the movie file fss = EasyDialogs.AskFileForOpen( wanted=File.FSSpec) # Was: QuickTime.MovieFileType if not fss: sys.exit(0) # Open the window bounds = (175, 75, 175 + 160, 75 + 120) theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0) # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil) Qd.SetPort(theWindow) # Get the movie theMovie = loadMovie(fss) # Relocate to (0, 0) bounds = theMovie.GetMovieBox() bounds = 0, 0, bounds[2] - bounds[0], bounds[3] - bounds[1] theMovie.SetMovieBox(bounds) # Create a controller theController = theMovie.NewMovieController(bounds, QuickTime.mcTopLeftMovie) # Get movie size and update window parameters rv, bounds = theController.MCGetControllerBoundsRect() theWindow.SizeWindow(bounds[2], bounds[3], 0) # XXXX or [3] [2]? Qt.AlignWindow(theWindow, 0) theWindow.ShowWindow() # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds) theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1') # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow) done = 0 while not done: gotone, evt = Evt.WaitNextEvent(0xffff, 0) (what, message, when, where, modifiers) = evt ## print what, message, when, where, modifiers # XXXX if theController.MCIsPlayerEvent(evt): continue if what == Events.mouseDown: part, whichWindow = Win.FindWindow(where) if part == Windows.inGoAway: done = whichWindow.TrackGoAway(where) elif part == Windows.inDrag: Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000)) elif what == Events.updateEvt: whichWindow = Win.WhichWindow(message) if not whichWindow: # Probably the console window. Print something, hope it helps. print 'update' else: Qd.SetPort(whichWindow) whichWindow.BeginUpdate() Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds()) whichWindow.EndUpdate()
#
"""Easy to use dialogs.
"""'echo' -- an AppleEvent handler which handles all events the same.
"""AEservertest - Test AppleEvent server interface
"""VerySimplePlayer converted to python
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[ i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i + 1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(_intRect(rect)) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i + 1] = newpos, self._panesizes[i + 1][1] self.makepanebounds() self.installbounds() self._calcbounds()