当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasBase.motion_notify_event方法代码示例

本文整理汇总了Python中matplotlib.backend_bases.FigureCanvasBase.motion_notify_event方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasBase.motion_notify_event方法的具体用法?Python FigureCanvasBase.motion_notify_event怎么用?Python FigureCanvasBase.motion_notify_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backend_bases.FigureCanvasBase的用法示例。


在下文中一共展示了FigureCanvasBase.motion_notify_event方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mouseMoveEvent

# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import motion_notify_event [as 别名]
 def mouseMoveEvent(self, event):
     x = event.x()
     # flipy so y=0 is bottom of canvas
     y = self.figure.bbox.height - event.y()
     FigureCanvasBase.motion_notify_event(self, x, y)
     if DEBUG:
         print("mouse move")
开发者ID:huard,项目名称:matplotlib,代码行数:9,代码来源:backend_qt.py

示例2: _update_pointer_position

# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import motion_notify_event [as 别名]
    def _update_pointer_position(self, guiEvent=None):
        """
        Figure out if we are inside the canvas or not and update the
        canvas enter/leave events
        """
        # if the pointer if over the canvas, set the lastx and lasty
        # attrs of the canvas so it can process event w/o mouse click
        # or move

        # the window's upper, left coords in screen coords
        xw = self._tkcanvas.winfo_rootx()
        yw = self._tkcanvas.winfo_rooty()
        # the pointer's location in screen coords
        xp, yp = self._tkcanvas.winfo_pointerxy()

        # not figure out the canvas coordinates of the pointer
        xc = xp - xw
        yc = yp - yw

        # flip top/bottom
        yc = self.figure.bbox.height - yc

        # JDH: this method was written originally to get the pointer
        # location to the backend lastx and lasty attrs so that events
        # like KeyEvent can be handled without mouse events.  Eg, if
        # the cursor is already above the axes, then key presses like
        # 'g' should toggle the grid.  In order for this to work in
        # backend_bases, the canvas needs to know _lastx and _lasty.
        # There are three ways to get this info the canvas:
        #
        # 1) set it explicity
        #
        # 2) call enter/leave events explicity.  The downside of this
        #    in the impl below is that enter could be repeatedly
        #    triggered if thes  mouse is over the axes and one is
        #    resizing with the keyboard.  This is not entirely bad,
        #    because the mouse position relative to the canvas is
        #    changing, but it may be surprising to get repeated entries
        #    without leaves
        #
        # 3) process it as a motion notify event.  This also has pros
        #    and cons.  The mouse is moving relative to the window, but
        #    this may surpise an event handler writer who is getting
        #   motion_notify_events even if the mouse has not moved

        # here are the three scenarios
        if 1:
            # just manually set it
            self._lastx, self._lasty = xc, yc
        elif 0:
            # alternate implementation: process it as a motion
            FigureCanvasBase.motion_notify_event(self, xc, yc, guiEvent)
        elif 0:
            # alternate implementation -- process enter/leave events
            # instead of motion/notify
            if self.figure.bbox.contains(xc, yc):
                self.enter_notify_event(guiEvent, xy=(xc,yc))
            else:
                self.leave_notify_event(guiEvent)
开发者ID:astraw,项目名称:matplotlib,代码行数:61,代码来源:backend_tkagg.py

示例3: motion_notify_event

# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import motion_notify_event [as 别名]
    def motion_notify_event(self, widget, event):
        if event.is_hint:
            t, x, y, state = event.window.get_pointer()
        else:
            x, y, state = event.x, event.y, event.get_state()

        # flipy so y=0 is bottom of canvas
        y = self.get_allocation().height - y
        FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
        return False  # finish event propagation?
开发者ID:jklymak,项目名称:matplotlib,代码行数:12,代码来源:backend_gtk3.py

示例4: motion_notify_event

# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import motion_notify_event [as 别名]
    def motion_notify_event(self, widget, event):
        if _debug: print 'FigureCanvasGTK.{0!s}'.format(fn_name())
        if event.is_hint:
            x, y, state = event.window.get_pointer()
        else:
            x, y, state = event.x, event.y, event.state

        # flipy so y=0 is bottom of canvas
        y = self.allocation.height - y
        FigureCanvasBase.motion_notify_event(self, x, y)
        return False  # finish event propagation?
开发者ID:runt18,项目名称:nupic,代码行数:13,代码来源:backend_gtk.py

示例5: mouseMoveEvent

# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import motion_notify_event [as 别名]
 def mouseMoveEvent(self, event):
     x, y = self.mouseEventCoords(event)
     FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
开发者ID:endolith,项目名称:matplotlib,代码行数:5,代码来源:backend_qt5.py

示例6: mouseMoveEvent

# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import motion_notify_event [as 别名]
 def mouseMoveEvent(self, event):
     x = event.x()
     # flipy so y=0 is bottom of canvas
     y = self.figure.bbox.height - event.y()
     FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
开发者ID:Acanthostega,项目名称:matplotlib,代码行数:7,代码来源:backend_qt5.py

示例7: handle

# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import motion_notify_event [as 别名]
    def handle(self, event):
        x=Fltk.Fl.event_x()
        y=Fltk.Fl.event_y()
        yf=self._source.figure.bbox.height - y
        if event == Fltk.FL_FOCUS or event == Fltk.FL_UNFOCUS:
            return 1
        elif event == Fltk.FL_KEYDOWN:
            ikey= Fltk.Fl.event_key()
            if(ikey<=255):
                self._key=chr(ikey)
            else:
                try:
                    self._key=special_key[ikey]
                except:
                    self._key=None
            
            # TODO: Handle ctrl, alt, super modifiers.
            FigureCanvasBase.key_press_event(self._source, self._key)
            return 1
        elif event == Fltk.FL_KEYUP:
            FigureCanvasBase.key_release_event(self._source, self._key)
            self._key=None
        elif event == Fltk.FL_PUSH:
            self.window().make_current()
            if Fltk.Fl.event_button1():
                self._button = 1
            elif  Fltk.Fl.event_button2():
                self._button = 2
            elif  Fltk.Fl.event_button3():
                self._button = 3
            else:
                self._button = None

            if self._draw_overlay:
                self._oldx=x
                self._oldy=y
            if Fltk.Fl.event_clicks():  # according to docs, event_clicks() returns nonzero if this is a double click.
                FigureCanvasBase.button_press_event(self._source, x, yf, self._button, dblclick=True)
                return 1
            else:
                FigureCanvasBase.button_press_event(self._source, x, yf, self._button)
                return 1
        elif event == Fltk.FL_ENTER:
            self.take_focus()
            return 1
        elif event == Fltk.FL_LEAVE:
            return 1
        elif event == Fltk.FL_MOVE:
            FigureCanvasBase.motion_notify_event(self._source, x, yf)
            return 1
        elif event == Fltk.FL_DRAG:
            self.window().make_current()
            if self._draw_overlay:
                self._dx=Fltk.Fl.event_x()-self._oldx
                self._dy=Fltk.Fl.event_y()-self._oldy
                Fltk.fl_overlay_rect(self._oldx,self._oldy,self._dx,self._dy)
            FigureCanvasBase.motion_notify_event(self._source, x, yf)
            return 1
        elif event == Fltk.FL_RELEASE:
            self.window().make_current()
            if self._draw_overlay:
                Fltk.fl_overlay_clear()
            FigureCanvasBase.button_release_event(self._source, x, yf, self._button)
            self._button = None
            return 1
        return 0
开发者ID:jcmdev0,项目名称:matplotlib,代码行数:68,代码来源:backend_fltkagg.py


注:本文中的matplotlib.backend_bases.FigureCanvasBase.motion_notify_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。