diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-05-21 04:09:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 04:09:30 (GMT) |
commit | 8b6175c2619c8fefa74a1ba33b8d37b6d13716e3 (patch) | |
tree | 6118f9d81ef058bdd439572676d9b4e6231528ac /Lib/idlelib | |
parent | d8981abb1c14589921eec42a877d143b85d861e0 (diff) | |
download | cpython-8b6175c2619c8fefa74a1ba33b8d37b6d13716e3.zip cpython-8b6175c2619c8fefa74a1ba33b8d37b6d13716e3.tar.gz cpython-8b6175c2619c8fefa74a1ba33b8d37b6d13716e3.tar.bz2 |
[3.12] gh-119174: Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry (GH-119175) (#119290)
gh-119174: Fix high DPI causes turtledemo(turtle-graphics examples) windows blurry (GH-119175)
------
(cherry picked from commit 538ed5e4818aa0d0aa759634e8bfa23e317434a1)
Co-authored-by: Wulian233 <71213467+Wulian233@users.noreply.github.com>
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/config.py | 3 | ||||
-rwxr-xr-x | Lib/idlelib/pyshell.py | 10 | ||||
-rw-r--r-- | Lib/idlelib/util.py | 15 |
3 files changed, 19 insertions, 9 deletions
diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py index 7fc08ef..6a5acac 100644 --- a/Lib/idlelib/config.py +++ b/Lib/idlelib/config.py @@ -158,8 +158,9 @@ class IdleConf: self.defaultCfg = {} self.userCfg = {} self.cfg = {} # TODO use to select userCfg vs defaultCfg + + # See https://bugs.python.org/issue4630#msg356516 for following. # self.blink_off_time = <first editor text>['insertofftime'] - # See https://bugs.python.org/issue4630#msg356516. if not _utest: self.CreateConfigHandlers() diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 1524fcc..d8b2652 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -11,15 +11,9 @@ except ImportError: "Your Python may not be configured for Tk. **", file=sys.__stderr__) raise SystemExit(1) -# Valid arguments for the ...Awareness call below are defined in the following. -# https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx if sys.platform == 'win32': - try: - import ctypes - PROCESS_SYSTEM_DPI_AWARE = 1 # Int required. - ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE) - except (ImportError, AttributeError, OSError): - pass + from idlelib.util import fix_win_hidpi + fix_win_hidpi() from tkinter import messagebox diff --git a/Lib/idlelib/util.py b/Lib/idlelib/util.py index a7ae74b..e05604a 100644 --- a/Lib/idlelib/util.py +++ b/Lib/idlelib/util.py @@ -12,11 +12,26 @@ TODO: * std streams (pyshell, run), * warning stuff (pyshell, run). """ +import sys # .pyw is for Windows; .pyi is for typing stub files. # The extension order is needed for iomenu open/save dialogs. py_extensions = ('.py', '.pyw', '.pyi') + +# Fix for HiDPI screens on Windows. CALL BEFORE ANY TK OPERATIONS! +# URL for arguments for the ...Awareness call below. +# https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx +if sys.platform == 'win32': # pragma: no cover + def fix_win_hidpi(): # Called in pyshell and turtledemo. + try: + import ctypes + PROCESS_SYSTEM_DPI_AWARE = 1 # Int required. + ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE) + except (ImportError, AttributeError, OSError): + pass + + if __name__ == '__main__': from unittest import main main('idlelib.idle_test.test_util', verbosity=2) |