8000 Fix cursor with toolmanager on GTK3. by QuLogic · Pull Request #20273 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix cursor with toolmanager on GTK3. #20273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
cursord = {} # deprecated in Matplotlib 3.5.


@functools.lru_cache()
def _mpl_to_gtk_cursor(mpl_cursor):
name = {
cursors.MOVE: "move",
cursors.HAND: "pointer",
cursors.POINTER: "default",
cursors.SELECT_REGION: "crosshair",
cursors.WAIT: "wait",
}[mpl_cursor]
return Gdk.Cursor.new_from_name(Gdk.Display.get_default(), name)


class TimerGTK3(TimerBase):
"""Subclass of `.TimerBase` using GTK3 timer events."""

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

@staticmethod
@functools.lru_cache()
def _mpl_to_gtk_cursor(mpl_cursor):
name = {
cursors.MOVE: "move",
cursors.HAND: "pointer",
cursors.POINTER: "default",
cursors.SELECT_REGION: "crosshair",
cursors.WAIT: "wait",
}[mpl_cursor]
return Gdk.Cursor.new_from_name(Gdk.Display.get_default(), name)

def set_cursor(self, cursor):
window = self.canvas.get_property("window")
if window is not None:
window.set_cursor(self._mpl_to_gtk_cursor(cursor))
window.set_cursor(_mpl_to_gtk_cursor(cursor))
Gtk.main_iteration()

def draw_rubberband(self, event, x0, y0, x1, y1):
Expand Down
294E
0