Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd38945

Browse files
committed
Merge pull request #1813 from mdboom/gtk3-version-check
GTK segfault with GTK3 and mpl_toolkits
2 parents 220306b + a35116c commit dd38945

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@
33
import os, sys
44
def fn_name(): return sys._getframe(1).f_code.co_name
55

6+
try:
7+
import gi
8+
except ImportError:
9+
raise ImportError("Gtk3 backend requires pygobject to be installed.")
10+
11+
try:
12+
gi.require_version("Gtk", "3.0")
13+
except ValueError:
14+
raise ImportError(
15+
"Gtk3 backend requires the GObject introspection bindings for Gtk 3 "
16+
"to be installed.")
17+
618
try:
719
from gi.repository import Gtk, Gdk, GObject
820
except ImportError:
9-
raise ImportError("GTK3 backend requires pygobject to be installed.")
21+
raise ImportError("Gtk3 backend requires pygobject to be installed.")
1022

1123
import matplotlib
1224
from matplotlib._pylab_helpers import Gcf

0 commit comments

Comments
 (0)