summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/run.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-09-21 08:20:06 (GMT)
committerGitHub <noreply@github.com>2017-09-21 08:20:06 (GMT)
commita96c96f5dab68d4e611af4b8caefd7268533fd9a (patch)
tree938b41feb0a8e91bbec971916156274469547ef5 /Lib/idlelib/run.py
parent3d1e2ab584ed0175592b5be2a0bc98dc1723776a (diff)
downloadcpython-a96c96f5dab68d4e611af4b8caefd7268533fd9a.zip
cpython-a96c96f5dab68d4e611af4b8caefd7268533fd9a.tar.gz
cpython-a96c96f5dab68d4e611af4b8caefd7268533fd9a.tar.bz2
bpo-31500: IDLE: Scale default fonts on HiDPI displays. (#3639)
Diffstat (limited to 'Lib/idlelib/run.py')
-rw-r--r--Lib/idlelib/run.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 9f6604b..39e0c11 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -184,6 +184,7 @@ def show_socket_error(err, address):
import tkinter
from tkinter.messagebox import showerror
root = tkinter.Tk()
+ fix_scaling(root)
root.withdraw()
msg = f"IDLE's subprocess can't connect to {address[0]}:{address[1]}.\n"\
f"Fatal OSError #{err.errno}: {err.strerror}.\n"\
@@ -277,6 +278,18 @@ def exit():
sys.exit(0)
+def fix_scaling(root):
+ """Scale fonts on HiDPI displays."""
+ import tkinter.font
+ scaling = float(root.tk.call('tk', 'scaling'))
+ if scaling > 1.4:
+ 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(-0.75*size)
+
+
class MyRPCServer(rpc.RPCServer):
def handle_error(self, request, client_address):