Skip to content

bpo-33656: On Windows, add API call saying that tk scales for DPI. #7137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------
Expand Down
8 changes: 8 additions & 0 deletions Lib/idlelib/NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
7 changes: 4 additions & 3 deletions Lib/idlelib/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please define PROCESS_SYSTEM_DPI_AWARE = 1 instead of using a magic number. It wouldn't hurt to quote MSDN in a brief comment that explains this value and also the MSDN URL for the PROCESS_DPI_AWARENESS enumeration.

Copy link
Member Author

@terryjreedy terryjreedy Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I made a new PR with both changes. It should make it into today's releases.
#7642.

except (AttributeError, OSError):
pass

import tkinter.messagebox as tkMessageBox
if TkVersion < 8.5:
root = Tk() # otherwise create root in main
Expand Down
Original file line number Diff line number Diff line change
@@ -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.