Skip to content

GTK backends #5793

Closed
Closed
@anntzer

Description

@anntzer

Currently, the FAQ lists the following possibilities for GTK-based interactive backends:

GTKAgg: Agg rendering to a GTK 2.x canvas (requires PyGTK)
GTK3Agg: Agg rendering to a GTK 3.x canvas (requires PyGObject)
GTK: GDK rendering to a GTK 2.x canvas (not recommended) (requires PyGTK)
GTKCairo: Cairo rendering to a GTK 2.x canvas (requires PyGTK and pycairo)
GTK3Cairo: Cairo rendering to a GTK 3.x canvas (requires PyGObject and pycairo)

In fact, it seems that cairocffi or pycairo is always needed (backend_gtk3agg.py line 12: from .backend_cairo import ...). But with cairocffi 0.7.2, I get

$ MPLBACKEND=gtk3agg python3 -c 'from pylab import *; plot([0, 1]); show()'
TypeError: Couldn't find foreign struct converter for 'cairo.Context'

During handling of the above exception, another exception occurred:

SystemError: <built-in method __instancecheck__ of GObjectMeta object at 0x2c8f1c8> returned a result with an error set

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/matplotlib/backends/backend_gtk3.py", line 343, in idle_draw
    self.draw()
  File "/usr/lib/python3.5/site-packages/matplotlib/backends/backend_gtk3.py", line 332, in draw
    if self.get_visible() and self.get_mapped():
SystemError: gi.FunctionInfo(get_visible) returned a result with an error set

and the same error without the chained traceback on Python2 (and no plot on the figure).

On the other hand, pycairo 1.10.1 seems to work fine on the same basic example, even though somewhat ironically, on Python3 it prints out the warning

/usr/lib/python3.5/site-packages/matplotlib/backends/backend_gtk3agg.py:18: UserWarning: The Gtk3Agg backend is known to not work on Python 3.x with pycairo. Try installing cairocffi.

Also, for Python2, pycairo seems to be a hard dependency of pygtk.

Unless there are plans to change/fix the issues, I would suggest to update the list of GTK-based backends to

GTK: GDK rendering to a GTK 2.x canvas (not recommended) (requires PyGTK; Python2 only)
GTKAgg: Agg rendering to a GTK 2.x canvas (requires PyGTK; Python2 only)
GTKCairo: Cairo rendering to a GTK 2.x canvas (requires PyGTK; Python2 only)
GTK3Agg: Agg rendering to a GTK 3.x canvas (requires PyGObject and cairocffi)
GTK3Cairo: Cairo rendering to a GTK 3.x canvas (requires PyGObject and cairocffi)

(I don't actually use gtk myself :-), I just want to see what combos I need to test for whether the status bar text supports unicode...)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions