embedding pylab

Hello, I am running WXAgg in a wxPython application.
Within my application I have embedded a python shell. From within the shell I want to run pyla. Will this conflict with WXAgg
running in my WXApp? Thanks.

Jeff

···

Jeffrey Thomas Peery

SeaMetrics, Inc.

Mechanical Engineer

JeffPeery@…674…

253.872.0285 (fax)

253.872.0284 (phone)


I think everything should work okay, so long as you setup matplotlib to use WXAgg as the backend before pylab is imported:

  import matplotlib
  matplotlib.use('WXAgg')
  import pylab

However, pylab will manage its figure windows separately from the FigureCanvasWxAgg instances you embed in your application. If you need tighter integration (e.g. opening new figures in tabs of a window you control), you'll need to write your own subclass of FigureManagerWx and make the WXAgg backend use it. I'm not quite clear as to how you go about doing so, but I'll be happy to help if I can.

Another caveat is that there is no way to make the figure frames children of another frame (e.g. the main window of your application). wxPython applications usually hang around until all of the parentless frames have been closed, so you could end up with an application that stays open until all of the figure frames have been closed. To prevent this, you'll need configure your wxApp instance to exit when the top window is closed:

  class MyApp(wx.PySimpleApp):
    def OnInit(self):
      wx.PySimpleApp.OnInit(self)
      frame = MyMainFrame() # create the main window
      self.SetTopWindow(frame)
      self.SetExitOnFrameDelete(True)

Ken

···

On Aug 10, 2005, at 2:54 PM, Jeff Peery wrote:

Hello, I am running WXAgg in a wxPython application. Within my application I have embedded a python shell. From within the shell I want to run pyla. Will this conflict with WXAgg running in my WXApp? Thanks.