Beispiel #1
0
    def forceFocus(self, cursorToo=True):

        # only force focus if window is viewable
        if not wutil.isViewable(self.top.winfo_id()):
            return
        # warp cursor
        # if no previous position, move to center
        gw = self.gwidget
        if gw:
            if gw.lastX is None or \
               (gw.lastX == 0 and gw.lastY == 0):
                swCurObj = gw.getSWCursor()
                if swCurObj:
                    gw.lastX = int(swCurObj.lastx*gw.winfo_width())
                    gw.lastY = int((1.-swCurObj.lasty)*gw.winfo_height())
                else:
                    gw.lastX = int(gw.winfo_width()/2.)
                    gw.lastY = int(gw.winfo_height()/2.)
            if cursorToo:
                wutil.moveCursorTo(gw.winfo_id(),
                                   gw.winfo_rootx(),
                                   gw.winfo_rooty(),
                                   gw.lastX,
                                   gw.lastY)

            # On non-X, "focus_force()" places focus on the gwidget canvas, but
            # this may not have the global focus; it may only be the widget seen
            # when the application itself has focus.  We may need to force the
            # app itself to have focus first, so we do that here too.
            wutil.forceFocusToNewWindow()
            gw.focus_force()
Beispiel #2
0
    def forceFocus(self, cursorToo=True):

        # only force focus if window is viewable
        if not wutil.isViewable(self.top.winfo_id()):
            return
        # warp cursor
        # if no previous position, move to center
        gw = self.gwidget
        if gw:
            if gw.lastX is None or \
               (gw.lastX == 0 and gw.lastY == 0):
                swCurObj = gw.getSWCursor()
                if swCurObj:
                    gw.lastX = int(swCurObj.lastx*gw.winfo_width())
                    gw.lastY = int((1.-swCurObj.lasty)*gw.winfo_height())
                else:
                    gw.lastX = int(gw.winfo_width()/2.)
                    gw.lastY = int(gw.winfo_height()/2.)
            if cursorToo:
                wutil.moveCursorTo(gw.winfo_id(),
                                   gw.winfo_rootx(),
                                   gw.winfo_rooty(),
                                   gw.lastX,
                                   gw.lastY)

            # On non-X, "focus_force()" places focus on the gwidget canvas, but
            # this may not have the global focus; it may only be the widget seen
            # when the application itself has focus.  We may need to force the
            # app itself to have focus first, so we do that here too.
            wutil.forceFocusToNewWindow()
            gw.focus_force()
    def tkplot_setcursor(self, cursornumber, x, y):

        gwidget = self.gwidget
        # wutil.MoveCursorTo uses 0,0 <--> upper left, need to convert
        sx = int(  x   * gwidget.winfo_width())
        sy = int((1-y) * gwidget.winfo_height())
        wutil.moveCursorTo(gwidget.winfo_id(), sx, sy)
    def forceFocus(self):

        # only force focus if window is viewable
        if not wutil.isViewable(self.top.winfo_id()):
            return
        # warp cursor
        # if no previous position, move to center
        gwidget = self.gwidget
        if gwidget:
            if gwidget.lastX is None:
                gwidget.lastX = gwidget.winfo_width()/2
                gwidget.lastY = gwidget.winfo_height()/2
            wutil.moveCursorTo(gwidget.winfo_id(),gwidget.lastX,gwidget.lastY)
            gwidget.focus_force()
Beispiel #5
0
    def tkplot_setcursor(self, cursornumber, x, y):

        gwidget = self.gwidget
        # Update the sw cursor object (A clear example of why this update
        # is needed is how 'apall' re-centers the cursor w/out changing y, when
        # the user types 'r'; without this update, the two cursors separate.)
        swCurObj = gwidget.getSWCursor()
        if swCurObj: swCurObj.moveTo(x, y, SWmove=1)
        # wutil.MoveCursorTo uses 0,0 <--> upper left, need to convert
        sx = int(  x   * gwidget.winfo_width())
        sy = int((1-y) * gwidget.winfo_height())
        rx = gwidget.winfo_rootx()
        ry = gwidget.winfo_rooty()
        # call the wutil version to move the cursor
        wutil.moveCursorTo(gwidget.winfo_id(), rx, ry, sx, sy)
Beispiel #6
0
    def tkplot_setcursor(self, cursornumber, x, y):

        gwidget = self.gwidget
        # Update the sw cursor object (A clear example of why this update
        # is needed is how 'apall' re-centers the cursor w/out changing y, when
        # the user types 'r'; without this update, the two cursors separate.)
        swCurObj = gwidget.getSWCursor()
        if swCurObj: swCurObj.moveTo(x, y, SWmove=1)
        # wutil.MoveCursorTo uses 0,0 <--> upper left, need to convert
        sx = int(x * gwidget.winfo_width())
        sy = int((1 - y) * gwidget.winfo_height())
        rx = gwidget.winfo_rootx()
        ry = gwidget.winfo_rooty()
        # call the wutil version to move the cursor
        wutil.moveCursorTo(gwidget.winfo_id(), rx, ry, sx, sy)
Beispiel #7
0
    def moveCursor(self, event):
        """Call back for mouse motion events"""

        # Kludge to handle the fact that Mac OS X x doesn't remember
        # software driven moves, the first move will just move nothing
        # but will properly update the coordinates
        if self._SWCursor.isLastSWmove:
            x = self._SWCursor.lastx
            y = self._SWCursor.lasty
            wutil.moveCursorTo(self.winfo_id(), int(x * self.winfo_width()), int((1.0 - y) * self.winfo_height()))
        else:
            x = (event.x + 0.5) / self.winfo_width()
            y = 1.0 - (event.y + 0.5) / self.winfo_height()
        self.activate()
        self._SWCursor.moveTo(x, y, SWmove=0)
Beispiel #8
0
    def moveCursor(self, event):
        """Call back for mouse motion events"""

        # Kludge to handle the fact that MacOS X (X11) doesn't remember
        # software driven moves, the first move will just move nothing
        # but will properly update the coordinates.  Do not do this under Aqua.
        if wutil.WUTIL_USING_X and self._SWCursor.isLastSWmove:
            x = self._SWCursor.lastx
            y = self._SWCursor.lasty
            wutil.moveCursorTo(self.winfo_id(), self.winfo_rootx(),
                               self.winfo_rooty(), int(x * self.winfo_width()),
                               int((1. - y) * self.winfo_height()))
        else:
            x = (event.x + 0.5) / self.winfo_width()
            y = 1. - (event.y + 0.5) / self.winfo_height()
        self._SWCursor.moveTo(x, y, SWmove=0)
Beispiel #9
0
    def moveCursor(self, event):
        """Call back for mouse motion events"""

        # Kludge to handle the fact that MacOS X (X11) doesn't remember
        # software driven moves, the first move will just move nothing
        # but will properly update the coordinates.  Do not do this under Aqua.
        if wutil.WUTIL_USING_X and self._SWCursor.isLastSWmove:
            x = self._SWCursor.lastx
            y = self._SWCursor.lasty
            wutil.moveCursorTo(self.winfo_id(),
                               self.winfo_rootx(),
                               self.winfo_rooty(),
                               int(x*self.winfo_width()),
                               int((1.-y)*self.winfo_height()))
        else:
            x = (event.x+0.5)/self.winfo_width()
            y = 1.-(event.y+0.5)/self.winfo_height()
        self._SWCursor.moveTo(x,y,SWmove=0)
Beispiel #10
0
    def gki_setcursor(self, arg):

        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_setcursor, arg)

        # get x and y
        cursorNumber = arg[0]
        x = gki.ndc(arg[1])
        y = gki.ndc(arg[2])
        # Update the sw cursor object (A clear example of why this update
        # is needed is how 'apall' re-centers the cursor w/out changing y, when
        # the user types 'r'; without this update, the two cursors separate.)
        swCurObj = self.__mca.getSWCursor()
        if swCurObj: swCurObj.moveTo(x, y, SWmove=1)
        # wutil.moveCursorTo uses 0,0 <--> upper left, need to convert
        sx = int(x * self.gwidget.winfo_width())
        sy = int((1 - y) * self.gwidget.winfo_height())
        rx = self.gwidget.winfo_rootx()
        ry = self.gwidget.winfo_rooty()
        # call the wutil version to move the cursor
        moveCursorTo(self.gwidget.winfo_id(), rx, ry, sx, sy)
Beispiel #11
0
    def gki_setcursor(self, arg):

        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_setcursor, arg)

        # get x and y
        cursorNumber = arg[0]
        x = gki.ndc(arg[1])
        y = gki.ndc(arg[2])
        # Update the sw cursor object (A clear example of why this update
        # is needed is how 'apall' re-centers the cursor w/out changing y, when
        # the user types 'r'; without this update, the two cursors separate.)
        swCurObj = self.__mca.getSWCursor()
        if swCurObj: swCurObj.moveTo(x, y, SWmove=1)
        # wutil.moveCursorTo uses 0,0 <--> upper left, need to convert
        sx = int(  x   * self.gwidget.winfo_width())
        sy = int((1-y) * self.gwidget.winfo_height())
        rx = self.gwidget.winfo_rootx()
        ry = self.gwidget.winfo_rooty()
        # call the wutil version to move the cursor
        moveCursorTo(self.gwidget.winfo_id(), rx, ry, sx, sy)