Commit 18c44cc0 authored by Cheryl Sabella's avatar Cheryl Sabella Committed by Terry Jan Reedy

[2.7] bpo-31500: IDLE: Scale default fonts on HiDPI displays. (GH-3639) (GH-6585)


(cherry picked from commit a96c96f5)
parent b53edb12
......@@ -107,8 +107,10 @@ class FileList:
def _test():
from idlelib.EditorWindow import fixwordbreaks
from idlelib.run import fix_scaling
import sys
root = Tk()
fix_scaling(root)
fixwordbreaks(root)
root.withdraw()
flist = FileList(root)
......
......@@ -1552,6 +1552,8 @@ def main():
# start editor and/or shell windows:
root = Tk(className="Idle")
root.withdraw()
from idlelib.run import fix_scaling
fix_scaling(root)
# set application icon
icondir = os.path.join(os.path.dirname(__file__), 'Icons')
......
......@@ -155,6 +155,7 @@ def show_socket_error(err, address):
import Tkinter
import tkMessageBox
root = Tkinter.Tk()
fix_scaling(root)
root.withdraw()
if err.args[0] == 61: # connection refused
msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\
......@@ -240,6 +241,19 @@ def exit():
capture_warnings(False)
sys.exit(0)
def fix_scaling(root):
"""Scale fonts on HiDPI displays."""
import tkFont
scaling = float(root.tk.call('tk', 'scaling'))
if scaling > 1.4:
for name in tkFont.names(root):
font = tkFont.Font(root=root, name=name, exists=True)
size = int(font['size'])
if size < 0:
font['size'] = int(round(-0.75*size))
class MyRPCServer(rpc.RPCServer):
def handle_error(self, request, client_address):
......
Default fonts now are scaled on HiDPI displays.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment