Hello--
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
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?
# end code snippet
In a similar fashion to the Matlab imagesc() function, I would like to embed a matplotlib image which displays a 2D matrix as a colormapped image. How might I be able to do this?
Nicholas
Nicholas Kinar wrote:
I've been following the sample code given in the wxPython distribution to embed a wxPython window in wxGTK.
As in embedding some wxPython in a C++ wxGTK program?
What I would like to do is embed matplotlib within a wxPanel of this wxPython script.
once you've got wxPython working, using MPL should be exactly t he same as with a pure wxPyton app -- take a look at the "embedded_in_wx" examples, and/or use wxMPL -- it provides a nice interactive MPL window out of the box:
http://agni.phys.iit.edu/~kmcivor/wxmpl/
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@...259...
As in embedding some wxPython in a C++ wxGTK program?
Yes, that is exactly what I am doing.
What I would like to do is embed
matplotlib within a wxPanel of this wxPython script.
once you've got wxPython working, using MPL should be exactly t he same
as with a pure wxPyton app -- take a look at the "embedded_in_wx"
examples, and/or use wxMPL -- it provides a nice interactive MPL window
out of the box:
http://agni.phys.iit.edu/~kmcivor/wxmpl/
-Chris
Chris, thank you very much for your response, and for the link. I've taken a look at the wxMPL library and it looks extremely useful and interesting. But how would I work with the class MyPanel(wx.Panel), and embed wxMPL directly into MyPanel? Could you give an extremely simple example (i.e. 2D plot of a sine wave)?
Nicholas
Nicholas Kinar wrote:
Chris, thank you very much for your response, and for the link. I've taken a look at the wxMPL library and it looks extremely useful and interesting. But how would I work with the class MyPanel(wx.Panel), and embed wxMPL directly into MyPanel? Could you give an extremely simple example (i.e. 2D plot of a sine wave)?
sorry -- very short on time -- look at the wxMPL examples, understand them with pure Python, and they it should be straightforward to transfer to your situation.
Note that you can put a wx.Panel in a wx.Panel, which is what you may want to do it your case.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@...259...
Note that you can put a wx.Panel in a wx.Panel, which is what you may want to do it your case.
-Chris
Hello Chris,
Thank you for your response; I think this is what I would like to do. Once again, thank you.
Nicholas