Matplotlib,避免在绘制时更新鼠标光标
Matplotlib, avoid update mouse cursor when draw
当使用 set_data
和 draw
方法更新绘图时,鼠标光标会在几毫秒内从箭头变为圆形。有可能避免这种情况吗?因为我每秒更新我的绘图 10 次,所以看到我的鼠标光标变化如此之快非常难看。
我正在使用 Python 3.6、PyQt5 和 matplotlib 2.1。提前谢谢你;)
这是 matplotlib 2.1 的新“功能”。
Busy Cursor
The interactive GUI backends will now change the cursor to busy when Matplotlib is rendering the canvas.
还有 this issue 关于不良行为。
我找到了一个解决方案:离开斧头时使用QApplication.restoreOverrideCursor()
,进入斧头时使用QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
。像这样:
self.figure.canvas.mpl_connect("axes_enter_event", self.figureEntree)
self.figure.canvas.mpl_connect("axes_leave_event", self.figureSortie)
def figureSortie(self, event):
QApplication.restoreOverrideCursor()
def figureEntree(self, event):
QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
如果您有工具栏,则可以调整 figureEntree
功能(沿工具栏更改光标 => 变量,当您 select 工具时更改)。
当使用 set_data
和 draw
方法更新绘图时,鼠标光标会在几毫秒内从箭头变为圆形。有可能避免这种情况吗?因为我每秒更新我的绘图 10 次,所以看到我的鼠标光标变化如此之快非常难看。
我正在使用 Python 3.6、PyQt5 和 matplotlib 2.1。提前谢谢你;)
这是 matplotlib 2.1 的新“功能”。
Busy Cursor
The interactive GUI backends will now change the cursor to busy when Matplotlib is rendering the canvas.
还有 this issue 关于不良行为。
我找到了一个解决方案:离开斧头时使用QApplication.restoreOverrideCursor()
,进入斧头时使用QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
。像这样:
self.figure.canvas.mpl_connect("axes_enter_event", self.figureEntree)
self.figure.canvas.mpl_connect("axes_leave_event", self.figureSortie)
def figureSortie(self, event):
QApplication.restoreOverrideCursor()
def figureEntree(self, event):
QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
如果您有工具栏,则可以调整 figureEntree
功能(沿工具栏更改光标 => 变量,当您 select 工具时更改)。