[Python-checkins] bpo-33656: On Windows, add API call saying that tk scales for DPI (GH-7137)
Terry Jan Reedy
webhook-mailer at python.org
Mon Jun 11 14:14:36 EDT 2018
https://github.com/python/cpython/commit/800415e3df69f494afe9f95a8563ce17609fe1da
commit: 800415e3df69f494afe9f95a8563ce17609fe1da
branch: master
author: Terry Jan Reedy <tjreedy at udel.edu>
committer: GitHub <noreply at github.com>
date: 2018-06-11T14:14:32-04:00
summary:
bpo-33656: On Windows, add API call saying that tk scales for DPI (GH-7137)
On Windows 8.1+ or 10, with DPI compatibility properties of the Python binary
unchanged, and a monitor resolution greater than 96 DPI, this should
make text and lines sharper. It should otherwise have no effect.
Using a magnifier, I determined that the improvement comes from horizontal and
lines being better lined up with the monitor pixels. I checked that this call causes
no problem on any Windows buildbot, including the Win7 buildbots. Unlike most
IDLE patches, this one can be easily reverted by users by removing a few lines,
at the top of idlelib/pyshell.py.
files:
A Misc/NEWS.d/next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst
M Doc/whatsnew/3.6.rst
M Lib/idlelib/NEWS.txt
M Lib/idlelib/configdialog.py
M Lib/idlelib/pyshell.py
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
index 37f8c4626494..bb3236190104 100644
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -1179,6 +1179,12 @@ colors for custom themes is added to Highlights tab of Settings dialog.
(Contributed by Cheryl Sabella and Terry Jan Reedy in :issue:`33642`,
:issue:`33768`, and :issue:`33679`)
+On Windows, a new API call tells Windows that tk scales for DPI. On Windows
+8.1+ or 10, with DPI compatibility properties of the Python binary
+unchanged, and a monitor resolution greater than 96 DPI, this should
+make text and lines sharper. It should otherwise have no effect.
+(Contributed by Terry Jan Reedy in :issue:`33656`).
+
importlib
---------
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 2f725b8ced9e..b10a4ba38ce6 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,14 @@ Released on 2018-06-18?
======================================
+bpo-33656: On Windows, add API call saying that tk scales for DPI.
+On Windows 8.1+ or 10, with DPI compatibility properties of the Python
+binary unchanged, and a monitor resolution greater than 96 DPI, this
+should make text and lines sharper. It should otherwise have no
+effect. If perchance it make text worse on your monitor, you can
+disable the ctypes.OleDLL call near the top of pyshell.py and report
+the problem on python-list or idle-dev at python.org.
+
bpo-33768: Clicking on a context line moves that line to the top
of the editor window.
diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py
index 7df69d5c4d64..75b917d0e193 100644
--- a/Lib/idlelib/configdialog.py
+++ b/Lib/idlelib/configdialog.py
@@ -373,11 +373,12 @@ def create_extension_frame(self, ext_name):
).grid(row=row, column=1, sticky=W, padx=7)
elif opt['type'] == 'int':
Entry(entry_area, textvariable=var, validate='key',
- validatecommand=(self.is_int, '%P')
+ validatecommand=(self.is_int, '%P'), width=10
).grid(row=row, column=1, sticky=NSEW, padx=7)
- else:
- Entry(entry_area, textvariable=var
+ else: # type == 'str'
+ # Limit size to fit non-expanding space with larger font.
+ Entry(entry_area, textvariable=var, width=15
).grid(row=row, column=1, sticky=NSEW, padx=7)
return
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index ee1313161da3..f39f15696e7e 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -8,6 +8,14 @@
print("** IDLE can't import Tkinter.\n"
"Your Python may not be configured for Tk. **", file=sys.__stderr__)
raise SystemExit(1)
+
+if sys.platform == 'win32':
+ import ctypes
+ try:
+ ctypes.OleDLL('shcore').SetProcessDpiAwareness(1)
+ except (AttributeError, OSError):
+ pass
+
import tkinter.messagebox as tkMessageBox
if TkVersion < 8.5:
root = Tk() # otherwise create root in main
diff --git a/Misc/NEWS.d/next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst b/Misc/NEWS.d/next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst
new file mode 100644
index 000000000000..e0c51b2c0f9e
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst
@@ -0,0 +1,4 @@
+On Windows, add API call saying that tk scales for DPI. On Windows
+8.1+ or 10, with DPI compatibility properties of the Python binary
+unchanged, and a monitor resolution greater than 96 DPI, this should
+make text and lines sharper. It should otherwise have no effect.
More information about the Python-checkins
mailing list