Debian Codegraph @

Lib/idlelib/util.py

raw
1 """
2 Idlelib objects with no external idlelib dependencies
3 which are needed in more than one idlelib module.
4
5 They are included here because
6 a) they don't particularly belong elsewhere; or
7 b) because inclusion here simplifies the idlelib dependency graph.
8
9 TODO:
10 * Python versions (editor and help_about),
11 * tk version and patchlevel (pyshell, help_about, maxos?, editor?),
12 * std streams (pyshell, run),
13 * warning stuff (pyshell, run).
14 """
15 import sys
16
17 # .pyw is for Windows; .pyi is for typing stub files.
18 # The extension order is needed for iomenu open/save dialogs.
19 py_extensions = ('.py', '.pyw', '.pyi')
20
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
35 if __name__ == '__main__':
36 from unittest import main
37 main('idlelib.idle_test.test_util', verbosity=2)