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
TypeError constructor returned NULL in wayland session #19405
Comments
Looks like the fix is diff --git i/lib/matplotlib/backends/backend_gtk3.py w/lib/matplotlib/backends/backend_gtk3.py
index e9e78b43e..486ba9c1e 100644
--- i/lib/matplotlib/backends/backend_gtk3.py
+++ w/lib/matplotlib/backends/backend_gtk3.py
@@ -36,12 +36,13 @@ backend_version = "%s.%s.%s" % (
Gtk.get_major_version(), Gtk.get_micro_version(), Gtk.get_minor_version())
try:
+ _display = Gdk.Display.get_default()
cursord = {
- cursors.MOVE: Gdk.Cursor.new(Gdk.CursorType.FLEUR),
- cursors.HAND: Gdk.Cursor.new(Gdk.CursorType.HAND2),
- cursors.POINTER: Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
- cursors.SELECT_REGION: Gdk.Cursor.new(Gdk.CursorType.TCROSS),
- cursors.WAIT: Gdk.Cursor.new(Gdk.CursorType.WATCH),
+ cursors.MOVE: Gdk.Cursor.new_from_name(_display, "move"),
+ cursors.HAND: Gdk.Cursor.new_from_name(_display, "pointer"),
+ cursors.POINTER: Gdk.Cursor.new_from_name(_display, "default"),
+ cursors.SELECT_REGION: Gdk.Cursor.new_from_name(_display, "crosshair"),
+ cursors.WAIT: Gdk.Cursor.new_from_name(_display, "wait"),
}
except TypeError as exc:
# Happens when running headless. Convert to ImportError to cooperate with (per https://developer.gnome.org/gdk3/stable/gdk3-Cursors.html, new_from_name exists since gtk2.8, and is preferred over using GdkCursorType (for which a note says "these IDs are directly taken from the X cursor font, and many of these cursors are either not useful, or are not available on other platforms.").) |
Thanks. Can confirm the fix works. The cursor changes to a different theme from the system default when hovering over the pyplot window, but that is a minor issue. Edit: everything works fine. No longer have the different cursor theme issue. |
@liuyun88 Would you be willing to open a PR with that patch? |
Just opened a PR. First time doing it and welcoming all suggestions and advice. |
Bug report
Bug summary
When trying to run matplotlib pyplot, and setting the backend to gtk3agg or gtk3cairo, the following error is encountered in wayland session. The same code works fine in Xorg, or using Qt backend.
Code for reproduction
Actual outcome
Expected outcome
No error should be encountered and the figure should show on the screen
Matplotlib version
import matplotlib; print(matplotlib.__version__)
): 3.3.3print(matplotlib.get_backend())
): GTK3AGG or GTK3CairoInstalled matplotlib from default manjaro/arch linux repository.
The text was updated successfully, but these errors were encountered: