Skip to content
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

gh-119174: Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry #119175

Merged
merged 7 commits into from
May 21, 2024
2 changes: 1 addition & 1 deletion Lib/idlelib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(self, _utest=False):
self.userCfg = {}
self.cfg = {} # TODO use to select userCfg vs defaultCfg
# self.blink_off_time = <first editor text>['insertofftime']
# See https:/bugs.python.org/issue4630, msg356516.
# See https://bugs.python.org/issue4630#msg356516

if not _utest:
self.CreateConfigHandlers()
Expand Down
11 changes: 11 additions & 0 deletions Lib/turtledemo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@

import turtle


Wulian233 marked this conversation as resolved.
Show resolved Hide resolved
demo_dir = os.path.dirname(os.path.abspath(__file__))
darwin = sys.platform == 'darwin'
win32 = sys.platform == 'win32'

STARTUP = 1
READY = 2
Expand Down Expand Up @@ -131,6 +133,15 @@ def __init__(self, filename=None):
root.title('Python turtle-graphics examples')
root.wm_protocol("WM_DELETE_WINDOW", self._destroy)

# See https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/ne-shellscalingapi-process_dpi_awareness
if win32:
try:
import ctypes
PROCESS_SYSTEM_DPI_AWARE = 1 # Int required.
ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
except (ImportError, AttributeError, OSError):
pass

if darwin:
import subprocess
# Make sure we are the currently activated OS X application
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry
Patch by Wulian233
terryjreedy marked this conversation as resolved.
Show resolved Hide resolved
Loading