From 285766b97cc040601dc4e27a541616a366a6e188 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sat, 26 May 2018 19:37:57 -0400 Subject: [PATCH 1/6] bpo-33656: turn on DPI awareness in IDLE on Windows --- Lib/idlelib/configdialog.py | 7 ++++--- Lib/idlelib/pyshell.py | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 36ac4a23a52dc0a..19be0fb78d4419e 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 ee1313161da3184..20561d0c54a61da 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -8,6 +8,13 @@ print("** IDLE can't import Tkinter.\n" "Your Python may not be configured for Tk. **", file=sys.__stderr__) raise SystemExit(1) + +import ctypes +try: + ctypes.windll.shcore.SetProcessDpiAwareness(True) +except AttributeError: + pass + import tkinter.messagebox as tkMessageBox if TkVersion < 8.5: root = Tk() # otherwise create root in main From 3e53570bc1ae07dfdcbec90878a187da81683cf4 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 8 Jun 2018 18:47:31 -0400 Subject: [PATCH 2/6] Check for Windows, use variant recommended by Eryk Sun --- Lib/idlelib/pyshell.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 20561d0c54a61da..f39f15696e7e017 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -9,11 +9,12 @@ "Your Python may not be configured for Tk. **", file=sys.__stderr__) raise SystemExit(1) -import ctypes -try: - ctypes.windll.shcore.SetProcessDpiAwareness(True) -except AttributeError: - pass +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: From 482fcfe829cfc56d89bf9c212ee6e44a020d7684 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 10 Jun 2018 18:05:36 -0400 Subject: [PATCH 3/6] Add blurb --- Misc/NEWS.d/next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst 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 000000000000000..d035c9bd12f4499 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst @@ -0,0 +1,2 @@ +Add Windows API call saying that tk scales for DPI. This should +either have no effect or make text and lines sharper. From 764c94ef0223ef936f6ce563a970bc0d15392773 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 11 Jun 2018 13:12:32 -0400 Subject: [PATCH 4/6] Revise blurb. --- .../next/IDLE/2018-06-10-17-59-36.bpo-33656.60ZqJS.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 index d035c9bd12f4499..e0c51b2c0f9ef7b 100644 --- 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 @@ -1,2 +1,4 @@ -Add Windows API call saying that tk scales for DPI. This should -either have no effect or make text and lines sharper. +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. From 9ebe1b898751371066e030ee0fa0945ed6da3839 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 11 Jun 2018 13:23:38 -0400 Subject: [PATCH 5/6] Add entry to idlelib-NEWS.txt. --- Lib/idlelib/NEWS.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 2f725b8ced9e837..b10a4ba38ce6011 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@python.org. + bpo-33768: Clicking on a context line moves that line to the top of the editor window. From 9109a08d0700d070860378fa731017c51038f29b Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 11 Jun 2018 13:32:23 -0400 Subject: [PATCH 6/6] Add entry for 3.6 What's New. --- Doc/whatsnew/3.6.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index 37f8c4626494de9..bb323619010400f 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 ---------