Integrating a plot to a GTK user interface
GTK is a user interface library that is especially popular on Linux environments. GTK is very complete, and its PyGObject binding for Python is especially convenient to use. In this recipe, we demonstrate how to interface GTK with matplotlib. We use the SuperShape application for this demonstration.
Getting ready
This recipe demonstrates how to use the latest Python binding for GTK, PyGObject. Thus, you will need to install PyGObject (most Linux distributions have a standard package for it) and obviously, GTK, if you don't have them already.
How to do it...
By now, if you have gone through the previous recipes on Tkinter and WxWidget, you will see a pattern in the way matplotlib integrates with the user interface. The pattern is the same here: Matplolib provides a canvas object specific to GTK, which embeds a Figure
instance. Integrating a plot to the GTK user interface can be done with the following steps:
We start with the necessary import directives...