Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter Output Blurry for icon and Text Python 2.7

I have trawled the net and can't seem to find a satisfactory answer. Whenever I run a program that has a Tkinter GUI it always seems blurry/fuzzy (which I assume is a low resolution). It seems much lower resolution than the Windows 10 OS that is running on a couple of computers that I run these programs on.

It doesn't matter what program I run I still get the same results for all types of Tkinter entities such as buttons, labels, file dialogues etc. Which is why I have not included a sample of code.

I have copied some examples below:

Tkinter FD

Tkinter Label

Is this something I should just expect or is there some of setting on the OS\Python\Tkinter that I need to alter.

Any help would be very much appreciated.

like image 374
SilverMerlin Avatar asked Jul 25 '26 21:07

SilverMerlin


1 Answers

It seems to be an OS tweak. I don't know the details (would be glad for an explanataion), but it does the job on Windows 10:

ctypes.windll.shcore.SetProcessDpiAwareness(1)

Call it before you initiate your GUI, i.e.:

import ctypes
.
.
.
if __name__ == "__main__":   
    if 'win' in sys.platform:
        ctypes.windll.shcore.SetProcessDpiAwareness(1)

    [call your Tkinter stuff]

Got it from here:

Attempting to resolve blurred tkinter text + scaling on Windows 10 high DPI displays, but concerned my approach is not Pythonic or is unsafe

like image 160
Jay Avatar answered Jul 28 '26 13:07

Jay