if TkVersion < 8.5:
root = Tk() # otherwise create root in main
root.withdraw()
+ from idlelib.run import fix_scaling
+ fix_scaling(root)
tkMessageBox.showerror("Idle Cannot Start",
"Idle requires tcl/tk 8.5+, not %s." % TkVersion,
parent=root)
NoDefaultRoot()
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')
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"\
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):