8000 Merge pull request #20273 from QuLogic/fix-toolmanager-gtk3 · matplotlib/matplotlib@d56e1b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d56e1b4

Browse files
authored
Merge pull request #20273 from QuLogic/fix-toolmanager-gtk3
Fix cursor with toolmanager on GTK3.
2 parents a6781fe + fc17b2d commit d56e1b4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@
4848
cursord = {} # deprecated in Matplotlib 3.5.
4949

5050

51+
@functools.lru_cache()
52+
def _mpl_to_gtk_cursor(mpl_cursor):
53+
name = {
54+
cursors.MOVE: "move",
55+
cursors.HAND: "pointer",
56+
cursors.POINTER: "default",
57+
cursors.SELECT_REGION: "crosshair",
58+
cursors.WAIT: "wait",
59+
}[mpl_cursor]
60+
return Gdk.Cursor.new_from_name(Gdk.Display.get_default(), name)
61+
62+
5163
class TimerGTK3(TimerBase):
5264
"""Subclass of `.TimerBase` using GTK3 timer events."""
5365

@@ -484,22 +496,10 @@ def set_message(self, s):
484496
escaped = GLib.markup_escape_text(s)
485497
self.message.set_markup(f'<small>{escaped}</small>')
486498

487-
@staticmethod
488-
@functools.lru_cache()
489-
def _mpl_to_gtk_cursor(mpl_cursor):
490-
name = {
491-
cursors.MOVE: "move",
492-
cursors.HAND: "pointer",
493-
cursors.POINTER: "default",
494-
cursors.SELECT_REGION: "crosshair",
495-
cursors.WAIT: "wait",
496-
}[mpl_cursor]
497-
return Gdk.Cursor.new_from_name(Gdk.Display.get_default(), name)
498-
499499
def set_cursor(self, cursor):
500500
window = self.canvas.get_property("window")
501501
if window is not None:
502-
window.set_cursor(self._mpl_to_gtk_cursor(cursor))
502+
window.set_cursor(_mpl_to_gtk_cursor(cursor))
503503
43AA Gtk.main_iteration()
504504

505505
def draw_rubberband(self, event, x0, y0, x1, y1):

0 commit comments

Comments
 (0)
0