Tkinter - Matplotlib toolbar opening toplevel window

Hello there,

I am new to Tkinter and want to integrate a matplotlib figure in a Tkinter window, as I am developing a basic GUI for other members of my team.
I was able to indeed have a plot in a Tkinter window, but whenever I hover the mouse over any of the matplotlib toolbar buttons, a Tkinter toplevel window opens. Just when “entering” the button area. If I keep “sweeping” the mouse cursor over the toolbar, several and several windows keep opening.
The buttons do work, by the way.

Follows my sample code:

import tkinter as tk
from tkinter.filedialog import asksaveasfile

from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import (
    FigureCanvasTkAgg, # interface between Figure class and Tkinter's Canvas
    NavigationToolbar2Tk # built-in toolbar for the figure
    )

tk_window = tk.Tk() # initializes Tkinter window
tk_window.title='Tkinter matplotlib integration'

mpl_figure = Figure(figsize=(5,4),dpi=200) # creates matplotlib figure
axs = mpl_figure.add_subplot()
axs.plot([1,2,3,4,5,6],[6,5,4,3,2,1])


tk_canvas = FigureCanvasTkAgg(mpl_figure, tk_window) # creates Tkinter Canvas
tk_canvas.draw()
toolbar = NavigationToolbar2Tk(tk_canvas, tk_window)
toolbar.update()

tk_canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)

tk_window.mainloop()

Any tips are appreciated.
Thanks!

If I run this I get the following in my terminal:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/home/tcaswell/.pybuild/bleeding/lib/python3.11/tkinter/__init__.py", line 1920, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 742, in enter
    toolTip.showtip(text)
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 762, in showtip
    self.tipwindow = tw = tk.Toplevel(self.widget)
                          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.pybuild/bleeding/lib/python3.11/tkinter/__init__.py", line 2652, in __init__
    self.title(root.title())
               ^^^^^^^^^^^^
TypeError: 'str' object is not callable

every time I move the mouse into a tool icon. I think the issue is that tk expects obj.title to be a method it can call to get/set the title. When you are setting the title you are replacing that method with a string which then fails later when we try to set the tool tip. Exactly why this fails by making many new windows is a question that is better asked to the Tk developers, but this change:

- tk_window.title='Tkinter matplotlib integration'
+ tk_window.title('Tkinter matplotlib integration')

makes your example work.