mirror of
https://github.com/python/cpython.git
synced 2025-10-05 22:51:56 +00:00
[3.6] bpo-31500: IDLE: Scale default fonts on HiDPI displays. (GH-3639) (#3686)
(cherry picked from commit a96c96f
)
This commit is contained in:
parent
88d0663005
commit
0c4997f191
4 changed files with 20 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue