From 9f246f95ec856b9f033e197f251eadeb768eac23 Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Mon, 26 Jan 2026 18:03:44 +0100 Subject: [PATCH 1/2] Make dpi_awareness compatible with Windows 11 --- FreeSimpleGUI/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/FreeSimpleGUI/__init__.py b/FreeSimpleGUI/__init__.py index 5925f37c..385a0b59 100644 --- a/FreeSimpleGUI/__init__.py +++ b/FreeSimpleGUI/__init__.py @@ -8571,10 +8571,15 @@ def set_options( if dpi_awareness is True: if running_windows(): - if platform.release() == '7': - ctypes.windll.user32.SetProcessDPIAware() - elif platform.release() == '8' or platform.release() == '10': - ctypes.windll.shcore.SetProcessDpiAwareness(1) + try: + if platform.release() == '7': + ctypes.windll.user32.SetProcessDPIAware() + # Windows 8, 10 and 11 use the following API + elif int(platform.release()) >= 8: + ctypes.windll.shcore.SetProcessDpiAwareness(1) + except TypeError: + # If platform.release isn't a number, just ignore the API + pass if scaling is not None: DEFAULT_SCALING = scaling From 1793d011997937a803e0f13aab1cf3207c0b5e8d Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Mon, 23 Mar 2026 14:41:28 +0100 Subject: [PATCH 2/2] Improve DPI awareness check for Windows Server Updated DPI awareness handling for Windows Server versions. --- FreeSimpleGUI/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/FreeSimpleGUI/__init__.py b/FreeSimpleGUI/__init__.py index 385a0b59..05544b81 100644 --- a/FreeSimpleGUI/__init__.py +++ b/FreeSimpleGUI/__init__.py @@ -8572,13 +8572,19 @@ def set_options( if dpi_awareness is True: if running_windows(): try: - if platform.release() == '7': + # Windows Server might return a string like "2022Server" on Python 3.13 + # whereas it would return 10 on Python 3.7 + # If we happen to find "server" in our release, let's just assume we're running + # a recent windows server version + if "Server" in platform.release(): + ctypes.windll.shcore.SetProcessDpiAwareness(1) + elif platform.release() == '7': ctypes.windll.user32.SetProcessDPIAware() # Windows 8, 10 and 11 use the following API elif int(platform.release()) >= 8: ctypes.windll.shcore.SetProcessDpiAwareness(1) - except TypeError: - # If platform.release isn't a number, just ignore the API + except (ValueError, TypeError): + # If platform.release isn't a number or cant be computed here, just igonore it pass if scaling is not None: