Displaying Matplotlib Navigation Toolbar in Tkinter via grid Displaying Matplotlib Navigation Toolbar in Tkinter via grid tkinter tkinter

Displaying Matplotlib Navigation Toolbar in Tkinter via grid


Can you create an empty frame, then put the NavigationToolbar in that frame? I assume the NavigationToolbar will then pack itself in that frame. You can then use grid on the frame.


Here is a code example for what was mentioned in Bryan Oakleys answer (add toolbar to frame, place frame on grid):

    fig = Figure(figsize=(5, 5), dpi=100)    canvas = FigureCanvasTkAgg(fig, master=root)    canvas.get_tk_widget().grid(row=1,column=4,columnspan=3,rowspan=20)    # here: plot suff to your fig    canvas.draw()    ###############    TOOLBAR    ###############    toolbarFrame = Frame(master=root)    toolbarFrame.grid(row=22,column=4)    toolbar = NavigationToolbar2TkAgg(canvas, toolbarFrame)


# the following works for me. I created an empty frame and display it using the grid# management system, so the frame will be able to use pack management systemcanvas = FigureCanvasTkAgg(fig, root)canvas.draw()canvas.get_tk_widget().grid(row=2, column=0)frame = Frame(root)frame.grid(row=0, column=1)toobar = NavigationToolbar2Tk(canvas, frame)canvas.get_tk_widget().grid(row=1, column=0)