diff --git a/.travis.yml b/.travis.yml index 59be49011f60..f92e87b1021a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -129,15 +129,15 @@ install: # install was successful by trying to import the toolkit (sometimes, the # install appears to be successful but shared libraries cannot be loaded at # runtime, so an actual import is a better check). - python -mpip install cairocffi pgi && + python -mpip install --upgrade cairocffi>=0.8 pgi>=0.0.11.2 && python -c 'import pgi as gi; gi.require_version("Gtk", "3.0"); from pgi.repository import Gtk' && echo 'pgi is available' || echo 'pgi is not available' - python -mpip install pyqt5 && + python -mpip install --upgrade pyqt5 && python -c 'import PyQt5.QtCore' && echo 'PyQt5 is available' || echo 'PyQt5 is not available' - python -mpip install -U \ + python -mpip install --upgrade \ -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04 \ wxPython && python -c 'import wx' && diff --git a/INSTALL.rst b/INSTALL.rst index d83228dfafd1..2f57527115d8 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -150,14 +150,17 @@ Optionally, you can also install a number of packages to enable better user interface toolkits. See :ref:`what-is-a-backend` for more details on the optional Matplotlib backends and the capabilities they provide. -* :term:`tk` (>= 8.3, != 8.6.0 or 8.6.1): for the TkAgg backend; +* :term:`tk` (>= 8.3, != 8.6.0 or 8.6.1): for the Tk-based backends; * `PyQt4 `_ (>= 4.4) or - `PySide `_: for the Qt4Agg backend; -* `PyQt5 `_: for the Qt5Agg backend; -* :term:`wxpython` (>= 4): for the WX or WXAgg backend; -* `cairocffi `_ (>=0.8) or + `PySide `_: for the Qt4-based backends; +* `PyQt5 `_: for the Qt5-based backends; +* `PyGObject `_ or + `pgi `_ (>= 0.0.11.2): for the GTK3-based + backends; +* :term:`wxpython` (>= 4): for the WX-based backends; +* `cairocffi `_ (>= 0.8) or `pycairo `_: for the cairo-based - backends (the latter is required for GTK3Cairo); + backends; * `Tornado `_: for the WebAgg backend; For better support of animation output format and image file formats, LaTeX, @@ -167,7 +170,7 @@ etc., you can install the following: `_: for saving movies; * `ImageMagick `_: for saving animated gifs; -* `Pillow `_ (>=3.4): for a larger +* `Pillow `_ (>= 3.4): for a larger selection of image file formats: JPEG, BMP, and TIFF image files; * `LaTeX `_ and `GhostScript `_ (for rendering text with LaTeX). diff --git a/lib/matplotlib/backends/_gtk3_compat.py b/lib/matplotlib/backends/_gtk3_compat.py index 5670e5375497..e0ac33c8d343 100644 --- a/lib/matplotlib/backends/_gtk3_compat.py +++ b/lib/matplotlib/backends/_gtk3_compat.py @@ -25,7 +25,7 @@ try: import pgi as gi except ImportError: - raise ImportError("The Gtk3 backend requires PyGObject or pgi") + raise ImportError("The GTK3 backends require PyGObject or pgi") from .backend_cairo import cairo # noqa # The following combinations are allowed: @@ -38,6 +38,8 @@ if gi.__name__ == "pgi" and cairo.__name__ == "cairo": raise ImportError("pgi and pycairo are not compatible") +if gi.__name__ == "pgi" and gi.version_info < (0, 0, 11, 2): + raise ImportError("The GTK3 backends are incompatible with pgi<0.0.11.2") gi.require_version("Gtk", "3.0") globals().update( {name: diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index 0d4d41420839..775ae88846a7 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -17,7 +17,8 @@ def _get_testable_interactive_backends(): backends = [] - for deps, backend in [(["cairocffi", "pgi"], "gtk3agg"), + # gtk3agg fails on Travis, needs to be investigated. + for deps, backend in [ # (["cairocffi", "pgi"], "gtk3agg"), (["cairocffi", "pgi"], "gtk3cairo"), (["PyQt5"], "qt5agg"), (["cairocffi", "PyQt5"], "qt5cairo"), @@ -34,16 +35,15 @@ def _get_testable_interactive_backends(): return backends -# 1. Using a timer not only allows testing of timers (on other backends), but -# is also necessary on gtk3 and wx, where a direct call to -# key_press_event("q") from draw_event causes breakage due to the canvas -# widget being deleted too early. -# 2. On gtk3, we cannot even test the timer setup (on Travis, which uses pgi) -# due to https://github.com/pygobject/pgi/issues/45. So we just cleanly -# exit from the draw_event. +# Using a timer not only allows testing of timers (on other backends), but is +# also necessary on gtk3 and wx, where a direct call to key_press_event("q") +# from draw_event causes breakage due to the canvas widget being deleted too +# early. Also, gtk3 redefines key_press_event with a different signature, so +# we directly invoke it from the superclass instead. _test_script = """\ import sys from matplotlib import pyplot as plt, rcParams +from matplotlib.backend_bases import FigureCanvasBase rcParams.update({ "webagg.open_in_browser": False, "webagg.port_retries": 1, @@ -53,13 +53,10 @@ def _get_testable_interactive_backends(): ax = fig.add_subplot(111) ax.plot([0, 1], [2, 3]) -if rcParams["backend"].startswith("GTK3"): - fig.canvas.mpl_connect("draw_event", lambda event: sys.exit(0)) -else: - timer = fig.canvas.new_timer(1) - timer.add_callback(fig.canvas.key_press_event, "q") - # Trigger quitting upon draw. - fig.canvas.mpl_connect("draw_event", lambda event: timer.start()) +timer = fig.canvas.new_timer(1) +timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q") +# Trigger quitting upon draw. +fig.canvas.mpl_connect("draw_event", lambda event: timer.start()) plt.show() """