winrt-Microsoft.UI.Interop 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: winrt-Microsoft.UI.Interop
3
+ Version: 2.1.0
4
+ Summary: Python projection of Windows Runtime (WinRT) APIs
5
+ License: MIT
6
+ Project-URL: Documentation, https://pywinrt.readthedocs.io
7
+ Project-URL: Repository, https://github.com/pywinrt/pywinrt
8
+ Project-URL: Changelog, https://github.com/pywinrt/pywinrt/blob/main/CHANGELOG.md
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: Implementation :: CPython
12
+ Classifier: Intended Audience :: Developers
13
+ Requires-Python: <3.13,>=3.9
14
+ Description-Content-Type: text/markdown
15
+
16
+ <!-- warning: Please don't edit this file. It was automatically generated. -->
17
+
18
+ # winrt-Microsoft.UI.Interop
19
+
20
+ Windows Runtime (WinRT) APIs for for the `Microsoft.UI.Interop` namespace.
21
+
22
+ This package provides the `winrt.microsoft.ui.interop` module.
@@ -0,0 +1,7 @@
1
+ <!-- warning: Please don't edit this file. It was automatically generated. -->
2
+
3
+ # winrt-Microsoft.UI.Interop
4
+
5
+ Windows Runtime (WinRT) APIs for for the `Microsoft.UI.Interop` namespace.
6
+
7
+ This package provides the `winrt.microsoft.ui.interop` module.
@@ -0,0 +1,187 @@
1
+ #include <Windows.h>
2
+
3
+ #include <Python.h>
4
+ #include <pythoncapi_compat.h>
5
+ #include <pybase.h>
6
+
7
+ #include <winrt/Microsoft.UI.Interop.h>
8
+ #include <py.Microsoft.UI.h>
9
+
10
+ // https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/win32/winrt-microsoft.ui.interop/
11
+ namespace py::cpp::Microsoft::UI::Interop
12
+ {
13
+ static PyObject* Interop_GetWindowIdFromWindow(
14
+ PyObject* /*unused*/, PyObject* arg) noexcept
15
+ {
16
+ auto ptr = PyLong_AsVoidPtr(arg);
17
+ if (!ptr && PyErr_Occurred())
18
+ {
19
+ return nullptr;
20
+ }
21
+
22
+ auto hwnd = static_cast<HWND>(ptr);
23
+
24
+ try
25
+ {
26
+ auto windowId = winrt::Microsoft::UI::GetWindowIdFromWindow(hwnd);
27
+ return py::converter<winrt::Microsoft::UI::WindowId>::convert(windowId);
28
+ }
29
+ catch (...)
30
+ {
31
+ py::to_PyErr();
32
+ return nullptr;
33
+ }
34
+ }
35
+
36
+ static PyObject* Interop_GetWindowFromWindowId(
37
+ PyObject* /*unused*/, PyObject* arg) noexcept
38
+ {
39
+ try
40
+ {
41
+ auto windowId
42
+ = py::converter<winrt::Microsoft::UI::WindowId>::convert_to(arg);
43
+ auto hwnd = winrt::Microsoft::UI::GetWindowFromWindowId(windowId);
44
+ return PyLong_FromVoidPtr(static_cast<void*>(hwnd));
45
+ }
46
+ catch (...)
47
+ {
48
+ py::to_PyErr();
49
+ return nullptr;
50
+ }
51
+ }
52
+
53
+ static PyObject* Interop_GetDisplayIdFromMonitor(
54
+ PyObject* /*unused*/, PyObject* arg) noexcept
55
+ {
56
+ auto ptr = PyLong_AsVoidPtr(arg);
57
+ if (!ptr && PyErr_Occurred())
58
+ {
59
+ return nullptr;
60
+ }
61
+
62
+ auto hmonitor = static_cast<HMONITOR>(ptr);
63
+
64
+ try
65
+ {
66
+ auto displayId = winrt::Microsoft::UI::GetDisplayIdFromMonitor(hmonitor);
67
+ return py::converter<winrt::Microsoft::UI::DisplayId>::convert(displayId);
68
+ }
69
+ catch (...)
70
+ {
71
+ py::to_PyErr();
72
+ return nullptr;
73
+ }
74
+ }
75
+
76
+ static PyObject* Interop_GetMonitorFromDisplayId(
77
+ PyObject* /*unused*/, PyObject* arg) noexcept
78
+ {
79
+ try
80
+ {
81
+ auto displayId
82
+ = py::converter<winrt::Microsoft::UI::DisplayId>::convert_to(arg);
83
+ auto hmonitor = winrt::Microsoft::UI::GetMonitorFromDisplayId(displayId);
84
+ return PyLong_FromVoidPtr(static_cast<void*>(hmonitor));
85
+ }
86
+ catch (...)
87
+ {
88
+ py::to_PyErr();
89
+ return nullptr;
90
+ }
91
+ }
92
+
93
+ static PyObject* Interop_GetIconIdFromIcon(
94
+ PyObject* /*unused*/, PyObject* arg) noexcept
95
+ {
96
+ auto ptr = PyLong_AsVoidPtr(arg);
97
+ if (!ptr && PyErr_Occurred())
98
+ {
99
+ return nullptr;
100
+ }
101
+
102
+ auto hicon = static_cast<HICON>(ptr);
103
+
104
+ try
105
+ {
106
+ auto iconId = winrt::Microsoft::UI::GetIconIdFromIcon(hicon);
107
+ return py::converter<winrt::Microsoft::UI::IconId>::convert(iconId);
108
+ }
109
+ catch (...)
110
+ {
111
+ py::to_PyErr();
112
+ return nullptr;
113
+ }
114
+ }
115
+
116
+ static PyObject* Interop_GetIconFromIconId(
117
+ PyObject* /*unused*/, PyObject* arg) noexcept
118
+ {
119
+ try
120
+ {
121
+ auto iconId = py::converter<winrt::Microsoft::UI::IconId>::convert_to(arg);
122
+ auto hicon = winrt::Microsoft::UI::GetIconFromIconId(iconId);
123
+ return PyLong_FromVoidPtr(static_cast<void*>(hicon));
124
+ }
125
+ catch (...)
126
+ {
127
+ py::to_PyErr();
128
+ return nullptr;
129
+ }
130
+ }
131
+
132
+ static PyMethodDef module_methods[]{
133
+ {"get_window_id_from_window",
134
+ &Interop_GetWindowIdFromWindow,
135
+ METH_O,
136
+ PyDoc_STR(
137
+ "Gets the WindowId that corresponds to the specified hwnd, if the provided HWND is valid.")},
138
+ {"get_window_from_window_id",
139
+ &Interop_GetWindowFromWindowId,
140
+ METH_O,
141
+ PyDoc_STR(
142
+ "Gets the window handle that corresponds to the specified windowId, if the provided windowId is valid and the system has an HWND that represents the window.")},
143
+ {"get_display_id_from_monitor",
144
+ &Interop_GetDisplayIdFromMonitor,
145
+ METH_O,
146
+ PyDoc_STR(
147
+ "Gets the DisplayId that corresponds to the specified hmonitor, if the provided HMONITOR is valid.")},
148
+ {"get_monitor_from_display_id",
149
+ &Interop_GetMonitorFromDisplayId,
150
+ METH_O,
151
+ PyDoc_STR(
152
+ "Gets the display monitor handle that corresponds to the specified displayId, if the provided displayId is valid and the system has an HMONITOR that represents the display monitor.")},
153
+ {"get_icon_id_from_icon",
154
+ &Interop_GetIconIdFromIcon,
155
+ METH_O,
156
+ PyDoc_STR(
157
+ "Gets the IconId that corresponds to the specified hicon, if the provided HICON is valid.")},
158
+ {"get_icon_from_icon_id",
159
+ &Interop_GetIconFromIconId,
160
+ METH_O,
161
+ PyDoc_STR(
162
+ "Gets the icon handle that corresponds to the specified iconId, if the provided iconId is valid and the system has an HICON that represents the icon.")},
163
+ {}};
164
+
165
+ PyDoc_STRVAR(module_doc, "UI Interop APIs.");
166
+
167
+ static PyModuleDef module_def
168
+ = {PyModuleDef_HEAD_INIT,
169
+ "_winrt_microsoft_ui_interop",
170
+ module_doc,
171
+ 0,
172
+ module_methods,
173
+ nullptr,
174
+ nullptr,
175
+ nullptr,
176
+ nullptr};
177
+
178
+ } // namespace py::cpp::Microsoft::UI::Interop
179
+
180
+ PyMODINIT_FUNC PyInit__winrt_microsoft_ui_interop(void) noexcept
181
+ {
182
+ using namespace py::cpp::Microsoft::UI::Interop;
183
+
184
+ py::pyobj_handle module{PyModule_Create(&module_def)};
185
+
186
+ return module.detach();
187
+ }
@@ -0,0 +1,44 @@
1
+ # WARNING: Please don't edit this file. It was automatically generated.
2
+
3
+ [build-system]
4
+ requires = ["setuptools", "winrt-sdk", "winrt-WindowsAppSDK"]
5
+ build-backend = "setuptools.build_meta"
6
+
7
+ [project]
8
+ name = "winrt-Microsoft.UI.Interop"
9
+ description = "Python projection of Windows Runtime (WinRT) APIs"
10
+ readme = "README.md"
11
+ license = { text = "MIT" }
12
+ classifiers = [
13
+ "Operating System :: Microsoft :: Windows",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: Implementation :: CPython",
16
+ "Intended Audience :: Developers",
17
+ ]
18
+ dynamic = ["version"]
19
+ requires-python = ">=3.9,<3.13"
20
+
21
+ [project.urls]
22
+ # Homepage = "https://github.com/pywinrt/pywinrt"
23
+ Documentation = "https://pywinrt.readthedocs.io"
24
+ Repository = "https://github.com/pywinrt/pywinrt"
25
+ Changelog = "https://github.com/pywinrt/pywinrt/blob/main/CHANGELOG.md"
26
+
27
+ [tool.setuptools.dynamic]
28
+ version = { file = "pywinrt-version.txt" }
29
+
30
+ [tool.setuptools.package-data]
31
+ "*" = ["*.pyi", "py.typed"]
32
+
33
+ [tool.cibuildwheel]
34
+ # use local winrt-sdk build dependency
35
+ environment = { PYTHONPATH="../../winrt-sdk/src;../../winrt-WindowsAppSDK/src" }
36
+ # don't install winrt-sdk from PyPI
37
+ build-frontend = { name = "build", args = ["--skip-dependency-check", "--no-isolation"] }
38
+ # don't build for PyPy
39
+ skip = "pp*"
40
+ # suppress warnings about ARM64 testing
41
+ test-skip = "*-win_arm64"
42
+
43
+ [tool.cibuildwheel.windows]
44
+ archs = ["x86", "AMD64", "ARM64"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,43 @@
1
+ # WARNING: Please don't edit this file. It was automatically generated.
2
+
3
+ from setuptools import Extension, setup
4
+ from setuptools.command.build_ext import build_ext
5
+ from winrt_sdk import get_include_dirs
6
+ from winrt_windows_app_sdk import get_include_dirs as get_app_sdk_include_dirs
7
+
8
+
9
+ try:
10
+ import os, pathlib
11
+
12
+ WINDOWS_APP_SDK_PATH = pathlib.Path(os.environ["WINDOWS_APP_SDK_PATH"]).resolve()
13
+ print(f"Using Windows App SDK from {WINDOWS_APP_SDK_PATH}")
14
+ except KeyError:
15
+ raise RuntimeError("Please set WINDOWS_APP_SDK_PATH environment variable")
16
+
17
+ class build_ext_ex(build_ext):
18
+ def build_extension(self, ext):
19
+ if self.compiler.compiler_type == "msvc":
20
+ ext.extra_compile_args = ["/std:c++20", "/permissive-"]
21
+ elif self.compiler.compiler_type == "mingw32":
22
+ ext.extra_compile_args = ["-std=c++20", "-D_WIN32_WINNT=_WIN32_WINNT_WIN10"]
23
+ ext.extra_link_args = ["-loleaut32"]
24
+ else:
25
+ raise ValueError(f"Unsupported compiler: {self.compiler.compiler_type}")
26
+
27
+ target = self.plat_name.replace("32", "-x86").replace("amd", "x").replace("win", "win10")
28
+ ext.library_dirs = [str(WINDOWS_APP_SDK_PATH / "lib" / target)]
29
+
30
+ build_ext.build_extension(self, ext)
31
+
32
+
33
+ setup(
34
+ cmdclass = {'build_ext': build_ext_ex},
35
+ ext_modules=[
36
+ Extension(
37
+ "winrt._winrt_microsoft_ui_interop",
38
+ sources=["py.Microsoft.UI.Interop.cpp"],
39
+ include_dirs=get_include_dirs()+ get_app_sdk_include_dirs()+ [str(WINDOWS_APP_SDK_PATH / "include")],
40
+ libraries=["windowsapp"],
41
+ )
42
+ ],
43
+ )
@@ -0,0 +1,10 @@
1
+ from winrt.microsoft.ui import IconId, DisplayId, WindowId
2
+
3
+ def get_window_id_from_window(hwnd: int) -> WindowId: ...
4
+ def get_window_from_window_id(window_id: WindowId) -> int: ...
5
+
6
+ def get_display_id_from_monitor(hmonitor: int) -> DisplayId: ...
7
+ def get_monitor_from_display_id(display_id: DisplayId) -> int: ...
8
+
9
+ def get_icon_id_from_icon(hicon: int) -> IconId: ...
10
+ def get_icon_from_icon_id(icon_id: IconId) -> int: ...
@@ -0,0 +1,18 @@
1
+ from .... import _winrt_microsoft_ui_interop as interop
2
+
3
+ __all__ = [
4
+ "get_window_id_from_window",
5
+ "get_window_from_window_id",
6
+ "get_display_id_from_monitor",
7
+ "get_monitor_from_display_id",
8
+ "get_icon_id_from_icon",
9
+ "get_icon_from_icon_id",
10
+ ]
11
+
12
+
13
+ get_window_id_from_window = interop.get_window_id_from_window
14
+ get_window_from_window_id = interop.get_window_from_window_id
15
+ get_display_id_from_monitor = interop.get_display_id_from_monitor
16
+ get_monitor_from_display_id = interop.get_monitor_from_display_id
17
+ get_icon_id_from_icon = interop.get_icon_id_from_icon
18
+ get_icon_from_icon_id = interop.get_icon_from_icon_id
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: winrt-Microsoft.UI.Interop
3
+ Version: 2.1.0
4
+ Summary: Python projection of Windows Runtime (WinRT) APIs
5
+ License: MIT
6
+ Project-URL: Documentation, https://pywinrt.readthedocs.io
7
+ Project-URL: Repository, https://github.com/pywinrt/pywinrt
8
+ Project-URL: Changelog, https://github.com/pywinrt/pywinrt/blob/main/CHANGELOG.md
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: Implementation :: CPython
12
+ Classifier: Intended Audience :: Developers
13
+ Requires-Python: <3.13,>=3.9
14
+ Description-Content-Type: text/markdown
15
+
16
+ <!-- warning: Please don't edit this file. It was automatically generated. -->
17
+
18
+ # winrt-Microsoft.UI.Interop
19
+
20
+ Windows Runtime (WinRT) APIs for for the `Microsoft.UI.Interop` namespace.
21
+
22
+ This package provides the `winrt.microsoft.ui.interop` module.
@@ -0,0 +1,12 @@
1
+ README.md
2
+ py.Microsoft.UI.Interop.cpp
3
+ pyproject.toml
4
+ pywinrt-version.txt
5
+ setup.py
6
+ winrt/_winrt_microsoft_ui_interop.pyi
7
+ winrt/microsoft/ui/interop/__init__.py
8
+ winrt/microsoft/ui/interop/py.typed
9
+ winrt_Microsoft.UI.Interop.egg-info/PKG-INFO
10
+ winrt_Microsoft.UI.Interop.egg-info/SOURCES.txt
11
+ winrt_Microsoft.UI.Interop.egg-info/dependency_links.txt
12
+ winrt_Microsoft.UI.Interop.egg-info/top_level.txt