summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-06-11 18:39:43 (GMT)
committerGitHub <noreply@github.com>2018-06-11 18:39:43 (GMT)
commit0404d35f9dc89748949935a9178d28bedde9d8c8 (patch)
tree5d9f8a829186af6c582b054c25fb12055dc8fbb6 /Lib
parent860d8c4a5e0d7cd96dd23f3f7996c97693ae3d55 (diff)
downloadcpython-0404d35f9dc89748949935a9178d28bedde9d8c8.zip
cpython-0404d35f9dc89748949935a9178d28bedde9d8c8.tar.gz
cpython-0404d35f9dc89748949935a9178d28bedde9d8c8.tar.bz2
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. (cherry picked from commit 800415e3df69f494afe9f95a8563ce17609fe1da) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/idlelib/NEWS.txt8
-rw-r--r--Lib/idlelib/configdialog.py7
-rwxr-xr-xLib/idlelib/pyshell.py8
3 files changed, 20 insertions, 3 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 33f0885..5d829b6 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,14 @@ Released on 2018-06-15?
======================================
+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.
diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py
index 7df69d5..75b917d 100644
--- a/Lib/idlelib/configdialog.py
+++ b/Lib/idlelib/configdialog.py
@@ -373,11 +373,12 @@ class ConfigDialog(Toplevel):
).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 ee13131..f39f156 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -8,6 +8,14 @@ except ImportError:
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