From: Jakob Cornell Date: Sun, 29 Dec 2024 21:15:47 +0000 (-0600) Subject: Force TkAgg Matplotlib backend on macOS X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9f9ed833e2dd4613e5d2d317865fa8e0b95ed3e;p=tutoring-tool.git Force TkAgg Matplotlib backend on macOS This fixes a crash caused by closing a generated plot window in the app. --- diff --git a/main.py b/main.py index 5128bc6..edf7f22 100644 --- a/main.py +++ b/main.py @@ -800,9 +800,10 @@ class AutoJsonStorageMgr: json.dump(data, f) -# This seems to be necessary for Pyinstaller builds; not sure why. +# The "macosx" backend is chosen by default on macOS and doesn't seem to play well with Tk. +# https://discuss.python.org/t/tkinter-pyplot-crashes-appkit-on-macos/75590 if sys.platform == "darwin": - matplotlib.use("macosx") + matplotlib.use("TkAgg") model = MainModel(AutoJsonStorageMgr('data'), AutoJsonStorageMgr('state')) view = MainView()