NavigationToolbar2Wx bug

Hi there

I am not 100% sure whether this is a bug or whether I do something wrong. However, I have the problem that the __init__ of NavigationToolbar2Wx does not take the parent of the wx.ToolBar as an input parameter. Instead it takes a canvas, and assumes that the parent of the canvas is the parent of the toolbar as well.

In my attached example however, the parent of the wx.ToolBar should be PlotFrame, whereas the parent of the canvas should be PlotWindow. As a result, the NavigationToolbar is not placed correctly in the frame, and sometimes invisible.

The same problem was already reported here:
http://matplotlib.1069221.n5.nabble.com/NavigationToolbar2WxAgg-Buttons-Disappear-td38516.html

My python version is 2.7.5 and matplotlib version is 1.1.1rc2.

A simple backward compatible solution to this problem is adding an optional frame parameter to the NavigationToolbar2Wx __init__ like this:

class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar):

def __init__(self, canvas, frame=None, can_kill=False):
         if frame=None:
wx.ToolBar.__init__(self, canvas.GetParent(), -1)
         else:
wx.ToolBar.__init__(self, frame, -1)
         NavigationToolbar2.__init__(self, canvas)

Could someone tell me whether this should be included into matplotlib like this?

With best regards
Matthias Baur

NavigationToolbar.py (1.72 KB)