2

in Windows 10, Tkinter can't undertand how to adjust its resolution when the system zoom factor changes (display setting: 100%, 125%, etc.. ). by default, it tries to do that, but the result is always a mess. in Ubuntu 22.04 this issue doesn't exist, and to solve it in Windows I used this piece of code:

from sys import platform

if platform == "win32":
    import ctypes
    try:
        ctypes.windll.shcore.SetProcessDpiAwareness(2) # windows >= 8.1
    except:
        ctypes.windll.user32.SetProcessDPIAware() # windows <= 8.0

with ctypes the zoom is fixed correctly, but only when I run the GUI at the first time. if the GUI is still in place, and the user changes the system zoom factor, for example from 125% to 150%, the zoom in my Tkinter application doesn't change.

so, my question is, is it possible to use ctypes in order to fix ALWAYS the Tkinter resolution in according the the zoom factor used by the system? ctypes should fix the resolution always and not just at the first time when I run the GUI.

TurboC
  • 777
  • 1
  • 5
  • 19
  • This is apparently a complicated problem (for which I am also seeking a solution). You may find some useful information in [this answer](https://stackoverflow.com/a/74105119/8512262) – JRiggles Apr 05 '23 at 14:37

0 Answers0