Problem with Tk-Backend

Hi everyone,

I’m new here and I have a question ( I guess as everybody who is new here :wink: ),

I’m having some strange problem with Matplotlib, using it in a Tkinter application.

I create a Canvas, a figure, subplot and then a toolbar. It works fine, but only without the toolbar! When I want to add the toolbar, I get an error

File “./”, line 102, in setupGUI
self.toolbar = NavigationToolbar2TkAgg( self.canvas, master )
File “/usr/lib/python2.4/site-packages/matplotlib/backends/”, line 537, in init

NavigationToolbar2.__init__(self, canvas)

File “/usr/lib/python2.4/site-packages/matplotlib/”, line 1107, in init
File “/usr/lib/python2.4/site-packages/matplotlib/backends/”, line 577, in _init_toolbar


File “/usr/lib/python2.4/lib-tk/”, line 2378, in init
Widget.init(self, master, ‘frame’, cnf, {}, extra)
File “/usr/lib/python2.4/lib-tk/”, line 1865, in init

_tkinter.TclError: bad screen distance “500.0”

Here is the part my code:

    self.canvFrame = Frame(master)
    self.canvFrame.pack(side=TOP, fill=BOTH, expand=1)

    self.canvFrame2 = Frame(self.canvFrame)
    self.canvFrame2.pack(side=LEFT, fill=BOTH, expand=1)
    self.f = Figure(figsize=(5,4), dpi=100)
    self.a = self.f.add_subplot(111)
    self.subplAxis = self.f.get_axes()
    self.canvas = FigureCanvasTkAgg(self.f, master=self.canvFrame2)
    self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
    self.toolbar = NavigationToolbar2TkAgg( self.canvas, self.canvFrame2 )
    self.canvas._tkcanvas.pack(side=TOP, fill=X, expand=1)

Master is a parameter passed to my method, which actually is set to Tk()

What did I get wrong? What is the problem? Thanks in advance…