擅长:python、mysql、java
<p>我用ctypes手动切换“DpiAwareness”,然后根据自己的喜好调整字体。别忘了“从ctypes导入windll”</p>
<pre><code>def fix_scaling(root):
"""Scale fonts on HiDPI displays.(Windows 10 only)"""
import tkinter.font
scaling = float(root.tk.call('tk', 'scaling'))
windll.shcore.SetProcessDpiAwareness(1)
if scaling < 15:
for name in tkinter.font.names(root):
font = tkinter.font.Font(root=root, name=name, exists=True)
size = int(font['size'])
if size > 0:
font['size'] = round(1.50*size)
</code></pre>