From b68e2bce1fe4b02a5418054e0ea5be36d9fb0b3d Mon Sep 17 00:00:00 2001 From: Wulian233 <1055917385@qq.com> Date: Sun, 19 May 2024 18:50:25 +0800 Subject: [PATCH 1/4] Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry --- Lib/idlelib/config.py | 2 +- Lib/turtledemo/__main__.py | 11 +++++++++++ .../2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py index 92992fd9cce9cd..bfd688610966f7 100644 --- a/Lib/idlelib/config.py +++ b/Lib/idlelib/config.py @@ -159,7 +159,7 @@ def __init__(self, _utest=False): self.userCfg = {} self.cfg = {} # TODO use to select userCfg vs defaultCfg # self.blink_off_time = ['insertofftime'] - # See https:/bugs.python.org/issue4630, msg356516. + # See https://bugs.python.org/issue4630#msg356516 if not _utest: self.CreateConfigHandlers() diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index 2ab6c15e2c079e..4cfa8a4a728e79 100755 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -96,8 +96,10 @@ import turtle + demo_dir = os.path.dirname(os.path.abspath(__file__)) darwin = sys.platform == 'darwin' +win32 = sys.platform == 'win32' STARTUP = 1 READY = 2 @@ -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 diff --git a/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst b/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst new file mode 100644 index 00000000000000..ab7745b191c4b5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst @@ -0,0 +1,2 @@ +Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry +Patch by Wulian233 \ No newline at end of file From f34358508b1bb1347a526b24471541eb883c8cae Mon Sep 17 00:00:00 2001 From: Wulian233 <71213467+Wulian233@users.noreply.github.com> Date: Sun, 19 May 2024 19:01:30 +0800 Subject: [PATCH 2/4] Update Lib/turtledemo/__main__.py Co-authored-by: Nice Zombies --- Lib/turtledemo/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index 4cfa8a4a728e79..2ed50af4aeb5f5 100755 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -96,7 +96,6 @@ import turtle - demo_dir = os.path.dirname(os.path.abspath(__file__)) darwin = sys.platform == 'darwin' win32 = sys.platform == 'win32' From 873d47ec8855b231f4be8881d537fc589afcab95 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 19 May 2024 13:44:07 -0400 Subject: [PATCH 3/4] Update Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst --- .../next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst b/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst index ab7745b191c4b5..3e7348c2348de8 100644 --- a/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst +++ b/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst @@ -1,2 +1,2 @@ Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry -Patch by Wulian233 \ No newline at end of file +Patch by Wulian233 From c4e6d7ec4c592e96fc720425289ae90d9130a8f9 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 20 May 2024 03:09:35 -0400 Subject: [PATCH 4/4] Update Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst --- .../Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst b/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst index 3e7348c2348de8..7b467b9ebd0d80 100644 --- a/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst +++ b/Misc/NEWS.d/next/Library/2024-05-19-18-49-04.gh-issue-119174.5GTv7d.rst @@ -1,2 +1,3 @@ Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry -Patch by Wulian233 +Patch by Wulian233 and Terry Jan Reedy +