意外发现了解决tkinter在windows下窗口非常不清晰的办法

网上找到的:

import ctypes
#告诉操作系统使用程序自身的dpi适配
ctypes.windll.shcore.SetProcessDpiAwareness(1)
#获取屏幕的缩放因子
ScaleFactor=ctypes.windll.shcore.GetScaleFactorForDevice(0)
#设置程序缩放
root.tk.call('tk', 'scaling', ScaleFactor/75)

我一般这么用:

# 为 windows 添加的 dpi 适配
if __import__('sys').platform.startswith('win'):
    try:
        shcore = __import__('ctypes').windll.shcore
        shcore.SetProcessDpiAwareness(1)
        root.tk.call('tk', 'scaling', shcore.GetScaleFactorForDevice(0)/75)
    except Exception:
        pass
77 views
Comments
登录后评论
Sign In
·

我因为解决不了,直接用PyQt5了 joy