Hello,
Kindly guide me using a simple step-by-step approach on embeding a matplotlib figure in a wxPython classic GUI.
The matplotlib documentation on WXAgg is difficult for me to uderstand. And I coldn't find a simple tutorial online.
Hope to hear from you soon.
Thanks for your time in advance.
My system configurations: Windows 7, Python 2.7.12, and wxPython 3.0-msw classic
# ========= MatPlotLib Figure Appear in Blue part while controls at right and bottom ================#
import wx
import wx.xrc
class MyFrame1 ( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 700,500 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer1 = wx.BoxSizer( wx.HORIZONTAL )
bSizer5 = wx.BoxSizer( wx.VERTICAL )
bSizer6 = wx.BoxSizer( wx.VERTICAL )
self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"MatPlotLib Graph Here\n\n?\n\n?", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
self.m_staticText3.Wrap( -1 )
self.m_staticText3.SetFont( wx.Font( 20, 70, 90, 90, False, wx.EmptyString ) )
self.m_staticText3.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) )
bSizer6.Add( self.m_staticText3, 1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5 )
bSizer5.Add( bSizer6, 1, wx.EXPAND, 5 )
bSizer7 = wx.BoxSizer( wx.VERTICAL )
self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Controls Here", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText1.Wrap( -1 )
self.m_staticText1.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNSHADOW ) )
bSizer7.Add( self.m_staticText1, 0, wx.ALL|wx.EXPAND, 5 )
bSizer5.Add( bSizer7, 0, wx.EXPAND, 5 )
bSizer1.Add( bSizer5, 1, wx.EXPAND, 5 )
bSizer8 = wx.BoxSizer( wx.VERTICAL )
self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Controls Here", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText2.Wrap( -1 )
self.m_staticText2.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNSHADOW ) )
bSizer8.Add( self.m_staticText2, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
bSizer1.Add( bSizer8, 0, wx.EXPAND, 5 )
self.SetSizer( bSizer1 )
self.Layout()
self.Centre( wx.BOTH )
def __del__( self ):
pass
app = wx.App()
frame = MyFrame1(None).Show()
app.MainLoop()
···
–
*Wouldn’t you rather do Business with us? *
This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete the
original. Any use of the email by you is prohibited. If you have received
this communication in error, please notify the author by replying to this
e-mail immediately.
www.BintaSMS.com <http://www.bintasms.com/>
www.BintaComputers.net <http://www.bintacomputers.net/>