I have a GUI app in built in custom tkinter, that uses a FigureCanvasTkAgg instance to embed a matplotlib figure. I also use a NavigationToolbar2Tk instance..well for navigation.
I all works fine, but I had an issue that if I ran the app on a screen with high DPI, then the buttons on the navigation bar became small relative to the other widgets, as well as the axes of the matplotlib figure.
I tried to figure it out, and searched online, but nothing seemed to work.
In many realated topics I saw this as a suggestion:
import ctypes
ctypes.windll.shcore.SetProcessDpiAwareness(2)
I tried it and everything turned enlarged and weird. I do not fully understand how this works, as I couldn’t locate the relevant documentation.
But when I changed it:
ctypes.windll.shcore.SetProcessDpiAwareness(1)
now it works perfectly… Intuitively I would think because the window now takes into consideration the DPI when showing the widgets, but I do not understand why this works.
Máté Sági- Kazár is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.