FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

WIP: throttle qt5 mouse motion events by tacaswell · Pull Request #4769 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 8 additions & 0 deletions lib/matplotlib/backends/backend_qt5.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import matplotlib

import time as ttime

from matplotlib.cbook import is_string_like
from matplotlib.backend_bases import FigureManagerBase
from matplotlib.backend_bases import FigureCanvasBase
Expand Down Expand Up @@ -242,6 +244,7 @@ def __init__(self, figure):
self._idle = True
w, h = self.get_width_height()
self.resize(w, h)
self._last_mouse_move_time = 0

def enterEvent(self, event):
FigureCanvasBase.enter_notify_event(self, guiEvent=event)
Expand Down Expand Up @@ -274,6 +277,11 @@ def mouseDoubleClickEvent(self, event):
print('button doubleclicked:', event.button())

def mouseMoveEvent(self, event):
cur_time = ttime.time()
if cur_time - self._last_mouse_move_time < 1 / 30:
return
self._last_mouse_move_time = cur_time

x = event.x()
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y()
Expand Down

Back | FazBrowse Home | New Git URL