Embedding a Matplotlib figure in a wxFrame
We will present examples by commenting each relevant source code block, and at the end, we will show the complete source code.
In the first example, we will describe how to embed a Matplotlib Figure
in a wxFrame
.
wxFrame
is one of the most important widgets in wxWidgets. It's considered to be a container because it contains other widgets. wxFrame
consists of a title bar, borders, and a center container area: the classic application window layout.
The example code starts with:
import wx
This is the main wxPython module. It contains all the submodules, objects, and functions for the wxWidgets library. Every application that uses wxPython imports this module.
from matplotlib.figure import Figure import numpy as np
These are the usual imports of Matplotlib Figure
and NumPy module.
from matplotlib.backends.backend_wxagg import \ FigureCanvasWxAgg as FigureCanvas
Here is the import of the backend-specific FigureCanvas
object: this class also inherits from...