Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
CloseEvent, KeyEvent, LocationEvent, MouseEvent, ResizeEvent)

try:
import gi
from gi import require_version as gi_require_version
except ImportError as err:
raise ImportError("The GTK3 backends require PyGObject") from err

try:
# :raises ValueError: If module/version is already loaded, already
# required, or unavailable.
gi.require_version("Gtk", "3.0")
gi_require_version("Gtk", "3.0")
# Also require GioUnix to avoid PyGIWarning when Gio is imported
# GioUnix is platform-specific and may not be available on all systems
try:
gi.require_version("GioUnix", "2.0")
gi_require_version("GioUnix", "2.0")
except ValueError:
# GioUnix is not available on this platform, which is fine
pass
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/backends/backend_gtk4.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
KeyEvent, LocationEvent, MouseEvent, ResizeEvent, CloseEvent)

try:
import gi
from gi import require_version as gi_require_version
except ImportError as err:
raise ImportError("The GTK4 backends require PyGObject") from err

try:
# :raises ValueError: If module/version is already loaded, already
# required, or unavailable.
gi.require_version("Gtk", "4.0")
gi_require_version("Gtk", "4.0")
# Also require GioUnix to avoid PyGIWarning when Gio is imported
# GioUnix is platform-specific and may not be available on all systems
try:
gi.require_version("GioUnix", "2.0")
gi_require_version("GioUnix", "2.0")
except ValueError:
# GioUnix is not available on this platform, which is fine
pass
Expand All @@ -29,6 +29,7 @@
# auto-backend selection logic correctly skips.
raise ImportError(e) from e

import gi
from gi.repository import Gio, GLib, Gtk, Gdk, GdkPixbuf
from . import _backend_gtk
from ._backend_gtk import ( # noqa: F401 # pylint: disable=W0611
Expand Down
Loading