Embedding matplotlib in wxPython embedded in wxGTK

Hello Che--

Thank you very much for your response; this is greatly appreciated, and thank you for the link to the scipy website. I've read over the example, but I cannot understand how I would start with just a wxPanel and then add the embedded matplotlib just to the panel (as per the code snippet above). In the example on the scipy website, it appears that class DemoPlotPanel(PlotPanel) takes as input class PlotPanel. How would I do this with the MyPanel class as shown above?

Nicholas

···

On 10-08-19 10:08 AM, C M wrote:

I've been following the sample code given in the wxPython distribution
to embed a wxPython window in wxGTK. The following links to the
wxPython SVN demonstrate this technique:

http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/samples/embedded/embedded_sample.py?revision=47031&view=markup
http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/samples/embedded/embedded.cpp?revision=52947&view=markup
     

Not sure what that is, but it doesn't look very helpful for your
needs. Instead, see below...

The main program (embedded.cpp) interacts with an embedded wxPython
script (embedded_sample.py). What I would like to do is embed
matplotlib within a wxPanel of this wxPython script. The following code
snippet shows exactly what I would like to do:

# Begin Python code snippet
import matplotlib
matplotlib.interactive( True )
matplotlib.use( 'WXAgg' )

import numpy as num
import wx

class MyPanel(wx.Panel):
         def __init__(self, parent):
             wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)

             # what do I do down here to be able to embed matplotlib
within the wxPanel?
     

See this page:
http://www.scipy.org/Matplotlib_figure_in_a_wx_panel

Basically the idea is you make a matplotlib canvas, and then add that
to a wxPanel.

Che