axon-shell 0.2.1__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 STofone
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: axon-shell
3
+ Version: 0.2.1
4
+ Summary: The native window layer for Axon apps: frameless window, drag regions, window control, native menu bridge. No UI, no CSS.
5
+ Author: STofone
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/AxonGUI/AxonShell
8
+ Project-URL: Homepage, https://github.com/AxonGUI/AxonShell
9
+ Project-URL: Issues, https://github.com/AxonGUI/AxonShell/issues
10
+ Keywords: axon,axon-gui,pyside6,qt,desktop,frameless-window,window-controls,native-menu
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Topic :: Desktop Environment :: Window Managers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: axon-gui>=5.3.4
19
+ Dynamic: license-file
20
+
21
+ <p align="center">
22
+ <img src="assets/axon-mark.svg" width="72" alt="Axon" />
23
+ </p>
24
+
25
+ # axon-shell
26
+
27
+ 给 [Axon](https://github.com/AxonGUI/Axon) 应用补上**网页做不了的那一层**:无边框窗口、可拖动的区域、窗口按钮的原生行为、窗口状态事件、原生菜单桥。
28
+
29
+ 这个包**不含任何界面**——没有标题栏、没有菜单条、没有按钮样式、没有主题、没有一行 CSS。标题栏长什么样、菜单怎么排、按钮用什么图标,全是你自己在页面里写的;它只负责让这些东西真的能拖动、能最小化、能关掉。
30
+
31
+ <sub>简体中文 · [English](README.en.md)</sub>
32
+
33
+ ---
34
+
35
+ ## 为什么需要它
36
+
37
+ 浏览器里做不出下面三件事,这三件也只有它们需要 Python:
38
+
39
+ 1. **无边框窗口**:去掉系统标题栏(`FramelessWindowHint`),整块界面归你;
40
+ 2. **拖动与缩放仍然有效**:Windows 上必须接管 `WM_NCHITTEST` 返回 `HTCAPTION`,系统才会给你真实的拖动、双击最大化、拖到边缘贴靠、四边缩放;Linux/macOS 上则退化成 `startSystemMove()` 与指针增量;
41
+ 3. **控制窗口**:最小化 / 最大化 / 还原 / 关闭 / 置顶 / 改尺寸,以及「窗口状态变了」的事件。
42
+
43
+ 其余全部是前端的事。所以这个包很小,也故意很小:你随时可以不用它,自己写 `Axon.Window` 的调用。
44
+
45
+ <p align="center"><img src="assets/screenshot.png" alt="示例:只有一条可拖动的顶栏和三个窗口按钮" width="760"></p>
46
+
47
+ ## 安装
48
+
49
+ `axon-gui` 与 `axon-shell` 都还没上 PyPI(上架后是两条 `pip install`)。现在:
50
+
51
+ ```bash
52
+ # 1) 框架本体:Release 里的 wheel(自带 PySide6)
53
+ pip install "https://github.com/AxonGUI/Axon/releases/download/v5.3.4/axon_gui-5.3.4-py3-none-any.whl"
54
+
55
+ # 2) 外观层。--no-deps:PyPI 上还没有 axon-gui,让 pip 自己解析会 404
56
+ pip install --no-deps "git+https://github.com/AxonGUI/AxonShell.git"
57
+ ```
58
+
59
+ 装完 `python -c "import axon, axon_shell"` 不报错就对了。
60
+
61
+ ## 三十秒接上
62
+
63
+ **Python 侧**——只换窗口类:
64
+
65
+ ```python
66
+ import sys
67
+ from PySide6.QtWidgets import QApplication
68
+ from axon import AxonController, AxonMagicGUI
69
+ from axon_shell import AxonShellWindow
70
+
71
+ WEB = "MainView"
72
+
73
+ @AxonController(WEB, id="App")
74
+ class App:
75
+ def hello(self, name: str) -> str:
76
+ return f"你好,{name}"
77
+
78
+ def main() -> int:
79
+ app = QApplication(sys.argv[:1])
80
+ AxonMagicGUI() # AxonShellWindow 内部要用
81
+ window = AxonShellWindow(WEB, "http://127.0.0.1:8000/", title="我的应用")
82
+ window.show()
83
+ return app.exec()
84
+
85
+ raise SystemExit(main())
86
+ ```
87
+
88
+ **页面侧**——写自己的标题栏,标两个属性就活了:
89
+
90
+ ```html
91
+ <script src="/axon.umd.cjs"></script> <!-- axon-gui 的 UMD 产物 -->
92
+ <script src="/axon-shell/shell.js"></script> <!-- 这个包唯一的 JS 文件 -->
93
+
94
+ <header data-axon-drag> <!-- 这块区域可以拖动窗口 -->
95
+ <span>我的应用</span>
96
+ <button data-axon-window="min">–</button> <!-- 三个按钮的行为自动接上 -->
97
+ <button data-axon-window="max">□</button>
98
+ <button data-axon-window="close">×</button>
99
+ </header>
100
+
101
+ <script>
102
+ (async () => {
103
+ await window.axon.AxonInit();
104
+ window.AxonShell.init(); // 接上拖拽区、按钮、状态事件
105
+ window.AxonShell.window.onState(s => console.log(s.frame));
106
+ })();
107
+ </script>
108
+ ```
109
+
110
+ `shell.js` 从包里取,静态服务挂到 `/axon-shell/` 即可:
111
+
112
+ ```python
113
+ from axon_shell import assets_dir
114
+ print(assets_dir()) # .../axon_shell/assets
115
+ ```
116
+
117
+ > `data-axon-drag` 里面的按钮、输入框、链接会自动被排除在拖动区之外;
118
+ > 不想被自动排除的,加 `data-axon-no-drag` 也可以反过来用。
119
+
120
+ ## 它提供什么
121
+
122
+ ### Python
123
+
124
+ | 名字 | 说明 |
125
+ | --- | --- |
126
+ | `AxonShellWindow(web_name, url, title=…, size=…, min_size=…, options=…)` | 继承 `AxonGUI`,去系统边框、设图标、初始尺寸不超出屏幕,注册 `Axon.Window` |
127
+ | `Axon.Window`(控制器) | `minimize` `maximize` `restore` `toggleMaximize` `toggleFullScreen` `close` `setAlwaysOnTop` `setTitle` `setDragRegions` `beginSystemMove` `moveTo` `resizeTo` `moveBy` `frame` `state` `platform` `popupMenu` `closeMenu` |
128
+ | 事件 `window:state` | 最大化 / 全屏 / 位置尺寸变化(60ms 合并后推一次) |
129
+ | 事件 `window:menu` | 原生菜单被选中:`{requestId, id}` |
130
+ | `assets_dir()` | `assets` 目录,里面只有 `shell.js`、图标 |
131
+
132
+ `Axon.Window` 是从 `axon-gui` 的通道调进去的,所以页面里也能直接写
133
+ `await Axon.Window.resizeTo(1200, 800)`,不必经过这个 JS 文件。
134
+
135
+ ### 前端(`window.AxonShell`)
136
+
137
+ | 名字 | 说明 |
138
+ | --- | --- |
139
+ | `init(opts?)` | 幂等安装:`data-axon-window` 点击、`[data-axon-drag]` 上报、状态/菜单事件订阅 |
140
+ | `drag.refresh()` / `drag.regions()` | 重新计算拖动区(布局变了要调);返回 `[{left,top,width,height}, …]` |
141
+ | `window.state()` | `{platform, frame:{x,y,width,height}, maximized, fullScreen}` |
142
+ | `window.minimize()` `toggleMaximize()` `close()` `setTitle()` `setAlwaysOnTop()` `refresh()` | 常用窗口操作 |
143
+ | `window.onState(cb)` | 订阅窗口状态 |
144
+ | `menu.native(spec)` / `menu.onSelect(cb)` | 让 Qt 弹原生菜单;`spec` 是 `{id?, title?, items:[…]}`,每项 `{id,label,shortcut?,kind?:separator/check/radio,checked?,disabled?,items?}` |
145
+ | `enableFallback()` | 非 win32/darwin 上补拖动与 8 向缩放(`init()` 会自动开) |
146
+
147
+ `init()` 之后 `<html>` 上会有 `data-axon-platform="win32|linux|darwin"` 与
148
+ `data-axon-maximized="true|false"`,你在 CSS 里可以据此调布局(比如去掉圆角)。
149
+
150
+ ## 各平台怎么动窗口
151
+
152
+ - **Windows**:Python 接管 `WM_NCHITTEST`——上报的拖动区返回 `HTCAPTION`,边框 6px 返回 `HTLEFT/HTRIGHT/HTTOP/...`。拖动、双击最大化、贴边、四边缩放全是系统行为,没有 JS 手搓的延迟。
153
+ - **Linux / macOS**:`startSystemMove()`(X11/macOS 支持);不支持时 `shell.js` 用指针增量 + `moveTo/resizeTo` 兜底,8 向缩放靠 8 条透明热区。
154
+
155
+ 所以拖动区只要「标出来」就行,不用写 `-webkit-app-region`(Qt 也不认这个)。
156
+
157
+ ## 示例
158
+
159
+ `examples/basic/` 是一个最小应用:一条可拖动的顶栏、三个窗口按钮、三行演示按钮。
160
+
161
+ ```bash
162
+ cd examples/basic
163
+ python main.py # 需要先 npm install axon-gui(或设 AXON_BUNDLE 指到 axon.umd.cjs)
164
+ python main.py --smoke # 无头自检
165
+ python ../../tests/verify.py # 端到端:拖拽区、按钮、状态、缩放、Python 往返、原生菜单
166
+ ```
167
+
168
+ 想看「照着这个自己写一整套 VSCode 外观」的完整例子,看
169
+ [Axon 文档里的窗口外观页](https://axongui.github.io/Axon/guide/window-chrome)。
170
+
171
+ ## 验证
172
+
173
+ ```bash
174
+ python examples/basic/main.py --smoke # 连通 + 拖拽区 + 窗口
175
+ python tests/verify.py # 11 条断言,退出码 = 失败数
176
+ ```
177
+
178
+ ## 版本
179
+
180
+ `0.2.0` —— 从「带皮肤」收缩成「只做原生那层」。之前的 0.1.x 包含标题栏/菜单/主题,
181
+ 现在都删了:那些东西你写得比我好。
182
+
183
+ MIT © STofone
@@ -0,0 +1,163 @@
1
+ <p align="center">
2
+ <img src="assets/axon-mark.svg" width="72" alt="Axon" />
3
+ </p>
4
+
5
+ # axon-shell
6
+
7
+ 给 [Axon](https://github.com/AxonGUI/Axon) 应用补上**网页做不了的那一层**:无边框窗口、可拖动的区域、窗口按钮的原生行为、窗口状态事件、原生菜单桥。
8
+
9
+ 这个包**不含任何界面**——没有标题栏、没有菜单条、没有按钮样式、没有主题、没有一行 CSS。标题栏长什么样、菜单怎么排、按钮用什么图标,全是你自己在页面里写的;它只负责让这些东西真的能拖动、能最小化、能关掉。
10
+
11
+ <sub>简体中文 · [English](README.en.md)</sub>
12
+
13
+ ---
14
+
15
+ ## 为什么需要它
16
+
17
+ 浏览器里做不出下面三件事,这三件也只有它们需要 Python:
18
+
19
+ 1. **无边框窗口**:去掉系统标题栏(`FramelessWindowHint`),整块界面归你;
20
+ 2. **拖动与缩放仍然有效**:Windows 上必须接管 `WM_NCHITTEST` 返回 `HTCAPTION`,系统才会给你真实的拖动、双击最大化、拖到边缘贴靠、四边缩放;Linux/macOS 上则退化成 `startSystemMove()` 与指针增量;
21
+ 3. **控制窗口**:最小化 / 最大化 / 还原 / 关闭 / 置顶 / 改尺寸,以及「窗口状态变了」的事件。
22
+
23
+ 其余全部是前端的事。所以这个包很小,也故意很小:你随时可以不用它,自己写 `Axon.Window` 的调用。
24
+
25
+ <p align="center"><img src="assets/screenshot.png" alt="示例:只有一条可拖动的顶栏和三个窗口按钮" width="760"></p>
26
+
27
+ ## 安装
28
+
29
+ `axon-gui` 与 `axon-shell` 都还没上 PyPI(上架后是两条 `pip install`)。现在:
30
+
31
+ ```bash
32
+ # 1) 框架本体:Release 里的 wheel(自带 PySide6)
33
+ pip install "https://github.com/AxonGUI/Axon/releases/download/v5.3.4/axon_gui-5.3.4-py3-none-any.whl"
34
+
35
+ # 2) 外观层。--no-deps:PyPI 上还没有 axon-gui,让 pip 自己解析会 404
36
+ pip install --no-deps "git+https://github.com/AxonGUI/AxonShell.git"
37
+ ```
38
+
39
+ 装完 `python -c "import axon, axon_shell"` 不报错就对了。
40
+
41
+ ## 三十秒接上
42
+
43
+ **Python 侧**——只换窗口类:
44
+
45
+ ```python
46
+ import sys
47
+ from PySide6.QtWidgets import QApplication
48
+ from axon import AxonController, AxonMagicGUI
49
+ from axon_shell import AxonShellWindow
50
+
51
+ WEB = "MainView"
52
+
53
+ @AxonController(WEB, id="App")
54
+ class App:
55
+ def hello(self, name: str) -> str:
56
+ return f"你好,{name}"
57
+
58
+ def main() -> int:
59
+ app = QApplication(sys.argv[:1])
60
+ AxonMagicGUI() # AxonShellWindow 内部要用
61
+ window = AxonShellWindow(WEB, "http://127.0.0.1:8000/", title="我的应用")
62
+ window.show()
63
+ return app.exec()
64
+
65
+ raise SystemExit(main())
66
+ ```
67
+
68
+ **页面侧**——写自己的标题栏,标两个属性就活了:
69
+
70
+ ```html
71
+ <script src="/axon.umd.cjs"></script> <!-- axon-gui 的 UMD 产物 -->
72
+ <script src="/axon-shell/shell.js"></script> <!-- 这个包唯一的 JS 文件 -->
73
+
74
+ <header data-axon-drag> <!-- 这块区域可以拖动窗口 -->
75
+ <span>我的应用</span>
76
+ <button data-axon-window="min">–</button> <!-- 三个按钮的行为自动接上 -->
77
+ <button data-axon-window="max">□</button>
78
+ <button data-axon-window="close">×</button>
79
+ </header>
80
+
81
+ <script>
82
+ (async () => {
83
+ await window.axon.AxonInit();
84
+ window.AxonShell.init(); // 接上拖拽区、按钮、状态事件
85
+ window.AxonShell.window.onState(s => console.log(s.frame));
86
+ })();
87
+ </script>
88
+ ```
89
+
90
+ `shell.js` 从包里取,静态服务挂到 `/axon-shell/` 即可:
91
+
92
+ ```python
93
+ from axon_shell import assets_dir
94
+ print(assets_dir()) # .../axon_shell/assets
95
+ ```
96
+
97
+ > `data-axon-drag` 里面的按钮、输入框、链接会自动被排除在拖动区之外;
98
+ > 不想被自动排除的,加 `data-axon-no-drag` 也可以反过来用。
99
+
100
+ ## 它提供什么
101
+
102
+ ### Python
103
+
104
+ | 名字 | 说明 |
105
+ | --- | --- |
106
+ | `AxonShellWindow(web_name, url, title=…, size=…, min_size=…, options=…)` | 继承 `AxonGUI`,去系统边框、设图标、初始尺寸不超出屏幕,注册 `Axon.Window` |
107
+ | `Axon.Window`(控制器) | `minimize` `maximize` `restore` `toggleMaximize` `toggleFullScreen` `close` `setAlwaysOnTop` `setTitle` `setDragRegions` `beginSystemMove` `moveTo` `resizeTo` `moveBy` `frame` `state` `platform` `popupMenu` `closeMenu` |
108
+ | 事件 `window:state` | 最大化 / 全屏 / 位置尺寸变化(60ms 合并后推一次) |
109
+ | 事件 `window:menu` | 原生菜单被选中:`{requestId, id}` |
110
+ | `assets_dir()` | `assets` 目录,里面只有 `shell.js`、图标 |
111
+
112
+ `Axon.Window` 是从 `axon-gui` 的通道调进去的,所以页面里也能直接写
113
+ `await Axon.Window.resizeTo(1200, 800)`,不必经过这个 JS 文件。
114
+
115
+ ### 前端(`window.AxonShell`)
116
+
117
+ | 名字 | 说明 |
118
+ | --- | --- |
119
+ | `init(opts?)` | 幂等安装:`data-axon-window` 点击、`[data-axon-drag]` 上报、状态/菜单事件订阅 |
120
+ | `drag.refresh()` / `drag.regions()` | 重新计算拖动区(布局变了要调);返回 `[{left,top,width,height}, …]` |
121
+ | `window.state()` | `{platform, frame:{x,y,width,height}, maximized, fullScreen}` |
122
+ | `window.minimize()` `toggleMaximize()` `close()` `setTitle()` `setAlwaysOnTop()` `refresh()` | 常用窗口操作 |
123
+ | `window.onState(cb)` | 订阅窗口状态 |
124
+ | `menu.native(spec)` / `menu.onSelect(cb)` | 让 Qt 弹原生菜单;`spec` 是 `{id?, title?, items:[…]}`,每项 `{id,label,shortcut?,kind?:separator/check/radio,checked?,disabled?,items?}` |
125
+ | `enableFallback()` | 非 win32/darwin 上补拖动与 8 向缩放(`init()` 会自动开) |
126
+
127
+ `init()` 之后 `<html>` 上会有 `data-axon-platform="win32|linux|darwin"` 与
128
+ `data-axon-maximized="true|false"`,你在 CSS 里可以据此调布局(比如去掉圆角)。
129
+
130
+ ## 各平台怎么动窗口
131
+
132
+ - **Windows**:Python 接管 `WM_NCHITTEST`——上报的拖动区返回 `HTCAPTION`,边框 6px 返回 `HTLEFT/HTRIGHT/HTTOP/...`。拖动、双击最大化、贴边、四边缩放全是系统行为,没有 JS 手搓的延迟。
133
+ - **Linux / macOS**:`startSystemMove()`(X11/macOS 支持);不支持时 `shell.js` 用指针增量 + `moveTo/resizeTo` 兜底,8 向缩放靠 8 条透明热区。
134
+
135
+ 所以拖动区只要「标出来」就行,不用写 `-webkit-app-region`(Qt 也不认这个)。
136
+
137
+ ## 示例
138
+
139
+ `examples/basic/` 是一个最小应用:一条可拖动的顶栏、三个窗口按钮、三行演示按钮。
140
+
141
+ ```bash
142
+ cd examples/basic
143
+ python main.py # 需要先 npm install axon-gui(或设 AXON_BUNDLE 指到 axon.umd.cjs)
144
+ python main.py --smoke # 无头自检
145
+ python ../../tests/verify.py # 端到端:拖拽区、按钮、状态、缩放、Python 往返、原生菜单
146
+ ```
147
+
148
+ 想看「照着这个自己写一整套 VSCode 外观」的完整例子,看
149
+ [Axon 文档里的窗口外观页](https://axongui.github.io/Axon/guide/window-chrome)。
150
+
151
+ ## 验证
152
+
153
+ ```bash
154
+ python examples/basic/main.py --smoke # 连通 + 拖拽区 + 窗口
155
+ python tests/verify.py # 11 条断言,退出码 = 失败数
156
+ ```
157
+
158
+ ## 版本
159
+
160
+ `0.2.0` —— 从「带皮肤」收缩成「只做原生那层」。之前的 0.1.x 包含标题栏/菜单/主题,
161
+ 现在都删了:那些东西你写得比我好。
162
+
163
+ MIT © STofone
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "axon-shell"
7
+ version = "0.2.1"
8
+ description = "The native window layer for Axon apps: frameless window, drag regions, window control, native menu bridge. No UI, no CSS."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "STofone" }]
13
+ keywords = ["axon", "axon-gui", "pyside6", "qt", "desktop", "frameless-window", "window-controls", "native-menu"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Topic :: Desktop Environment :: Window Managers",
18
+ "License :: OSI Approved :: MIT License",
19
+ ]
20
+ dependencies = ["axon-gui>=5.3.4"]
21
+
22
+ [project.urls]
23
+ Repository = "https://github.com/AxonGUI/AxonShell"
24
+ Homepage = "https://github.com/AxonGUI/AxonShell"
25
+ Issues = "https://github.com/AxonGUI/AxonShell/issues"
26
+
27
+ [tool.setuptools]
28
+ package-dir = { "" = "src" }
29
+ packages = ["axon_shell"]
30
+
31
+ [tool.setuptools.package-data]
32
+ axon_shell = ["assets/*.js", "assets/*.svg", "assets/*.png", "assets/*.ico"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ """axon-shell —— 给 Axon 应用一层可复用的「桌面应用外观」。
2
+
3
+ 它不是框架核心:`axon-gui` 只管通道与窗口基类,这个包只提供
4
+ 「VSCode 那种观感」需要的两半——Python 侧的无边框窗口,以及前端皮肤。
5
+ """
6
+
7
+ from .window import AxonShellWindow, AxonWindow, WindowBridge, assets_dir
8
+
9
+ __all__ = ["AxonShellWindow", "AxonWindow", "WindowBridge", "assets_dir"]
10
+ __version__ = "0.2.1"