Tkinter Matplotlib NavigationToolbar2Tk renders incorrectly and buttons are bugged on MacOS, any solutions to fix this?

Viewed 98

I am trying to implement a navigation toolbar that works with my graph that is embedded into Tkinter. When displayed, it looks broken, with the icons pushed into the bottom right corner and the buttons do not work correctly and sometimes get stuck. I am on MacOS BigSur.

Code to replicate:

import tkinter as tk
from PIL import ImageTk, Image 

from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk) 
from matplotlib.figure import Figure

root = tk.Tk()

figure = Figure(figsize = (7.5, 5.19), dpi = 100)
line = figure.add_subplot(111)
canvas = FigureCanvasTkAgg(figure, master = root)
canvasToolBar = NavigationToolbar2Tk(canvas, window = root)

canvas.get_tk_widget().pack()
canvasToolBar.pack()
line.plot([0,1,2,3,4,5], [0,1,2,3,4,5], marker='o')
canvas.draw()

root.mainloop()

enter image description here

I have noticed previously that some elements of Tkinter work incorrectly on a Mac system, so is this another problem Mac users will face or is the implementation of the toolbar incorrect?

0 Answers
Related