Skip to content

Commit 98e7db9

Browse files
authored
build python module + add WIndowControls to python module
2 parents 23772b2 + 5265e09 commit 98e7db9

3 files changed

Lines changed: 82 additions & 4 deletions

File tree

.github/workflows/build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v3
1515

16+
# - name: Python version
17+
# uses: actions/setup-python@v5
18+
# with:
19+
# python-version: 3.13
20+
1621
- name: Run script
1722
run: |
1823
chmod +x ./build_linux_gtk3.sh
1924
sudo apt update
2025
./build_linux_gtk3.sh --dependencies --deploy --tests
26+
cd HUI-linux-x86_64-webkit-gtk3
27+
python3 ../build_python.py
28+
2129
2230
- name: Upload build artifacts
2331
uses: actions/upload-artifact@v4
@@ -34,10 +42,22 @@ jobs:
3442
- name: Checkout repository
3543
uses: actions/checkout@v3
3644

45+
- name: Python version
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: 3.13
49+
50+
- name: MSVC cmd
51+
uses: TheMrMilchmann/setup-msvc-dev@v3
52+
with:
53+
arch: x64
54+
3755
- name: Run script
3856
run: |
3957
choco install 7zip -y
4058
./build_win_cef.bat --dependencies --deploy --tests
59+
cd HUI-win-AMD64-blink-cef
60+
python ../build_python.py
4161
4262
- name: Upload build artifacts
4363
uses: actions/upload-artifact@v4

build_python.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
libpath = sys.base_prefix # C:\Program Files\Python312
2727
pyname = "python"+str(sys.version_info.major)+str(sys.version_info.minor) # python312
2828
suffix = sysconfig.get_config_var('EXT_SUFFIX') # .cp312-win_amd64.pyd
29-
os.system("call \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat\" && cl /LD /EHsc /O2 /Fe:HUI"+suffix+" ../hui_python.cc "+includes+" /I\"..\" /link /LIBPATH:\""+libpath+"\\libs"+"\" "+pyname+".lib libHUI.lib")
29+
#os.system("call \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat\" && cl /LD /EHsc /O2 /Fe:HUI"+suffix+" ../hui_python.cc "+includes+" /I\"..\" /link /LIBPATH:\""+libpath+"\\libs"+"\" "+pyname+".lib libHUI.lib")
30+
os.system("cl /LD /EHsc /O2 /Fe:HUI"+suffix+" ../hui_python.cc "+includes+" /I\"..\" /link /LIBPATH:\""+libpath+"\\libs"+"\" "+pyname+".lib libHUI.lib")
3031

3132
print("done")
3233

@@ -56,7 +57,7 @@
5657
print("unsupported os, sorry")
5758

5859

59-
input()
60+
6061

6162
"""
6263
OLD NOTES:
@@ -81,4 +82,4 @@
8182
8283
8384
84-
"""
85+
"""

hui_python.cc

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,64 @@ PYBIND11_MODULE(HUI, m) {
4242
.def("exit", &WebView::exit)
4343

4444
;
45+
46+
47+
py::class_<WindowControls>(m, "WindowControls")
48+
.def(py::init<void*, void*>(), py::arg("backend"), py::arg("handle"))
49+
50+
.def("set_type", &WindowControls::set_type, py::arg("type"))
51+
.def("get_type", &WindowControls::get_type)
52+
53+
.def("set_layer", &WindowControls::set_layer, py::arg("layer"))
54+
.def("get_layer", &WindowControls::get_layer)
55+
56+
.def("set_geometry", &WindowControls::set_geometry, py::arg("geometry"))
57+
.def("get_geometry", &WindowControls::get_geometry)
58+
59+
.def("set_opacity", &WindowControls::set_opacity, py::arg("opacity"))
60+
.def("get_opacity", &WindowControls::get_opacity)
61+
62+
.def("set_id", &WindowControls::set_id, py::arg("id"))
63+
.def("get_id", &WindowControls::get_id)
64+
65+
.def("set_title", &WindowControls::set_title, py::arg("title"))
66+
.def("get_title", &WindowControls::get_title)
67+
68+
.def("set_exclusive_zone", &WindowControls::set_exclusive_zone, py::arg("zone"))
69+
.def("get_exclusive_zone", &WindowControls::get_exclusive_zone)
4570

46-
// TODO: WindowControls
71+
.def("set_focused", &WindowControls::set_focused, py::arg("activated"))
72+
.def("get_focused", &WindowControls::get_focused)
73+
74+
.def("set_input_mode_keyboard", &WindowControls::set_input_mode_keyboard, py::arg("mode"))
75+
.def("get_input_mode_keyboard", &WindowControls::get_input_mode_keyboard)
76+
77+
;
78+
4779

80+
m.attr("WT_TOPLEVEL_SSD") = WT_TOPLEVEL_SSD;
81+
m.attr("WT_TOPLEVEL_CSD") = WT_TOPLEVEL_CSD;
82+
m.attr("WT_DESKTOP_COMPONENT") = WT_DESKTOP_COMPONENT;
83+
m.attr("WT_POPOVER") = WT_POPOVER;
84+
85+
m.attr("WL_BACKGROUND") = WL_BACKGROUND;
86+
m.attr("WL_BOTTOM") = WL_BOTTOM;
87+
m.attr("WL_TOP") = WL_TOP;
88+
m.attr("WL_OVERLAY") = WL_OVERLAY;
89+
m.attr("WL_TOPLEAST") = WL_TOPLEAST;
90+
m.attr("WL_TOPMOST") = WL_TOPMOST;
91+
92+
m.attr("WS_HIDDEN") = WS_HIDDEN;
93+
m.attr("WS_NOT_HIDDEN") = WS_NOT_HIDDEN;
94+
m.attr("WS_MINIMIZED") = WS_MINIMIZED;
95+
m.attr("WS_NOT_MINIMIZED") = WS_NOT_MINIMIZED;
96+
m.attr("WS_FULLSCREEN") = WS_FULLSCREEN;
97+
m.attr("WS_NOT_FULLSCREEN") = WS_NOT_FULLSCREEN;
98+
m.attr("WS_MAXIMIZED") = WS_MAXIMIZED;
99+
m.attr("WS_NOT_MAXIMIZED") = WS_NOT_MAXIMIZED;
100+
101+
m.attr("WIM_ALWAYS") = WIM_ALWAYS;
102+
m.attr("WIM_AUTO_WINDOW") = WIM_AUTO_WINDOW;
103+
m.attr("WIM_NEVER") = WIM_NEVER;
104+
48105
}

0 commit comments

Comments
 (0)