Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f7303cd

Browse filesBrowse files
[3.13] gh-119174: Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry (GH-119175) (#119289)
gh-119174: Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry (GH-119175) ------ (cherry picked from commit 538ed5e) Co-authored-by: Wulian233 <71213467+Wulian233@users.noreply.github.com>
1 parent 24b0e8d commit f7303cd
Copy full SHA for f7303cd

File tree

5 files changed

+26
-11
lines changed
Filter options

5 files changed

+26
-11
lines changed

‎Lib/idlelib/config.py

Copy file name to clipboardExpand all lines: Lib/idlelib/config.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ def __init__(self, _utest=False):
158158
self.defaultCfg = {}
159159
self.userCfg = {}
160160
self.cfg = {} # TODO use to select userCfg vs defaultCfg
161+
162+
# See https://bugs.python.org/issue4630#msg356516 for following.
161163
# self.blink_off_time = <first editor text>['insertofftime']
162-
# See https://bugs.python.org/issue4630#msg356516.
163164

164165
if not _utest:
165166
self.CreateConfigHandlers()

‎Lib/idlelib/pyshell.py

Copy file name to clipboardExpand all lines: Lib/idlelib/pyshell.py
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@
1111
"Your Python may not be configured for Tk. **", file=sys.__stderr__)
1212
raise SystemExit(1)
1313

14-
# Valid arguments for the ...Awareness call below are defined in the following.
15-
# https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx
1614
if sys.platform == 'win32':
17-
try:
18-
import ctypes
19-
PROCESS_SYSTEM_DPI_AWARE = 1 # Int required.
20-
ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
21-
except (ImportError, AttributeError, OSError):
22-
pass
15+
from idlelib.util import fix_win_hidpi
16+
fix_win_hidpi()
2317

2418
from tkinter import messagebox
2519

‎Lib/idlelib/util.py

Copy file name to clipboardExpand all lines: Lib/idlelib/util.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,26 @@
1212
* std streams (pyshell, run),
1313
* warning stuff (pyshell, run).
1414
"""
15+
import sys
1516

1617
# .pyw is for Windows; .pyi is for typing stub files.
1718
# The extension order is needed for iomenu open/save dialogs.
1819
py_extensions = ('.py', '.pyw', '.pyi')
1920

21+
22+
# Fix for HiDPI screens on Windows. CALL BEFORE ANY TK OPERATIONS!
23+
# URL for arguments for the ...Awareness call below.
24+
# https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx
25+
if sys.platform == 'win32': # pragma: no cover
26+
def fix_win_hidpi(): # Called in pyshell and turtledemo.
27+
try:
28+
import ctypes
29+
PROCESS_SYSTEM_DPI_AWARE = 1 # Int required.
30+
ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
31+
except (ImportError, AttributeError, OSError):
32+
pass
33+
34+
2035
if __name__ == '__main__':
2136
from unittest import main
2237
main('idlelib.idle_test.test_util', verbosity=2)

‎Lib/turtledemo/__main__.py

Copy file name to clipboardExpand all lines: Lib/turtledemo/__main__.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@
9292
from idlelib.colorizer import ColorDelegator, color_config
9393
from idlelib.percolator import Percolator
9494
from idlelib.textview import view_text
95+
import turtle
9596
from turtledemo import __doc__ as about_turtledemo
9697

97-
import turtle
98+
if sys.platform == 'win32':
99+
from idlelib.util import fix_win_hidpi
100+
fix_win_hidpi()
98101

99102
demo_dir = os.path.dirname(os.path.abspath(__file__))
100103
darwin = sys.platform == 'darwin'
101-
102104
STARTUP = 1
103105
READY = 2
104106
RUNNING = 3
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry
2+
Patch by Wulian233 and Terry Jan Reedy
3+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.