decoui 0.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.
- decoui-0.1.0/.gitignore +220 -0
- decoui-0.1.0/LICENSE +21 -0
- decoui-0.1.0/PKG-INFO +211 -0
- decoui-0.1.0/README.md +187 -0
- decoui-0.1.0/pyproject.toml +49 -0
- decoui-0.1.0/src/decoui/icon.png +0 -0
decoui-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
history.db
|
|
220
|
+
.claude
|
decoui-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 luvMagi
|
|
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.
|
decoui-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: decoui
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Decorator-driven GUI framework for Python — generate PySide6 UIs from type annotations
|
|
5
|
+
Project-URL: Homepage, https://github.com/luvmagi/decoui
|
|
6
|
+
Project-URL: Repository, https://github.com/luvmagi/decoui
|
|
7
|
+
Project-URL: Issues, https://github.com/luvmagi/decoui/issues
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: decorator,framework,gui,pyside6,qt,ui
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: pyside6>=6.6.0
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# decoui
|
|
26
|
+
|
|
27
|
+
Decorator-driven GUI framework for Python. Annotate your methods — decoui generates a full PySide6 desktop app automatically.
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- **Zero UI code** — decorate a class and its methods, call `gui_main()`
|
|
36
|
+
- **Native type mapping** — `str`, `int`, `float`, `bool`, `list`, `dict`, `Enum` → widgets automatically
|
|
37
|
+
- **Async execution** — every tool runs in a thread; stdout and `logging` are captured in real time
|
|
38
|
+
- **Execution history** — every run is persisted to SQLite with parameters, logs, and status
|
|
39
|
+
- **Replay** — restore any past run's parameters with one click
|
|
40
|
+
- **Light theme** — clean built-in stylesheet, Consolas / 微软雅黑 / Meiryo font stack
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install decoui
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Requires Python 3.10+ and PySide6 6.6+.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import logging
|
|
58
|
+
from decoui import tool, toolset, gui_main
|
|
59
|
+
|
|
60
|
+
@toolset(label="Text Tools", tags=["text"])
|
|
61
|
+
class TextTools:
|
|
62
|
+
|
|
63
|
+
@tool(label="Count Characters",
|
|
64
|
+
description="Count chars, words and lines.",
|
|
65
|
+
placeholders={"content": "Paste text here…"})
|
|
66
|
+
def count(self, content: str = "") -> str:
|
|
67
|
+
words = len(content.split())
|
|
68
|
+
logging.info("words=%d", words)
|
|
69
|
+
return f"{len(content)} chars / {words} words"
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
gui_main(title="My Tools")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`gui_main()` auto-discovers every `@toolset` class in the caller's global scope — no explicit registration needed.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## API Reference
|
|
80
|
+
|
|
81
|
+
### `@toolset`
|
|
82
|
+
|
|
83
|
+
Applied to a class. Groups its `@tool` methods under one sidebar entry.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
@toolset(
|
|
87
|
+
label="CSV Tools", # required — sidebar display name
|
|
88
|
+
tags=["file", "batch"], # optional — used by the tag filter bar
|
|
89
|
+
description="...", # optional — tooltip on hover in the sidebar
|
|
90
|
+
)
|
|
91
|
+
class CsvTools:
|
|
92
|
+
...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
| Parameter | Type | Description |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| `label` | `str` | Required. Display name in the sidebar. |
|
|
98
|
+
| `tags` | `list[str]` | Tag filter bar labels. Multiple tags = AND filter. |
|
|
99
|
+
| `description` | `str` | Shown as a tooltip when hovering the toolset in the nav tree. |
|
|
100
|
+
|
|
101
|
+
### `@tool`
|
|
102
|
+
|
|
103
|
+
Applied to a method inside a `@toolset` class.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
@tool(
|
|
107
|
+
label="Merge Files",
|
|
108
|
+
description="Merge multiple files into one.",
|
|
109
|
+
placeholders={"files": "one path per line"},
|
|
110
|
+
confirm=True, # show confirmation dialog before running
|
|
111
|
+
timeout=120, # cancel after N seconds (None = unlimited)
|
|
112
|
+
)
|
|
113
|
+
def merge(self, files: list, output: str = "out.txt") -> str:
|
|
114
|
+
...
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Parameter | Type | Default | Description |
|
|
118
|
+
|---|---|---|---|
|
|
119
|
+
| `label` | `str` | required | Tool display name. |
|
|
120
|
+
| `description` | `str` | `""` | Shown in a bordered box below the title. |
|
|
121
|
+
| `placeholders` | `dict[str,str]` | `{}` | Placeholder text per parameter name. |
|
|
122
|
+
| `confirm` | `bool` | `False` | Show a Yes/No confirmation dialog before running. |
|
|
123
|
+
| `timeout` | `int\|None` | `None` | Execution timeout in seconds. |
|
|
124
|
+
|
|
125
|
+
### `gui_main`
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
gui_main(title="My App", db_path="~/.myapp/history.db")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Parameter | Type | Default | Description |
|
|
132
|
+
|---|---|---|---|
|
|
133
|
+
| `title` | `str` | `"decoui"` | Window title. |
|
|
134
|
+
| `db_path` | `str\|Path\|None` | `~/.decoui/history.db` | SQLite database path for execution history. |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Type → Widget Mapping
|
|
139
|
+
|
|
140
|
+
| Python annotation | Widget | Notes |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `str` | `QLineEdit` | Single-line text. |
|
|
143
|
+
| `int` | `QSpinBox` | Integer, full int range. |
|
|
144
|
+
| `float` | `QDoubleSpinBox` | 4 decimal places. |
|
|
145
|
+
| `bool` | `QCheckBox` | Checked / unchecked. |
|
|
146
|
+
| `list` | `QTextEdit` | One item per line or comma-separated. |
|
|
147
|
+
| `dict` | `QTextEdit` | JSON input; parsed with `json.loads` then `ast.literal_eval`. Raises on invalid input. |
|
|
148
|
+
| `Enum` subclass | `QComboBox` | Dropdown of enum members. |
|
|
149
|
+
|
|
150
|
+
- Required parameters (no default) are marked with a red `*` in the form label.
|
|
151
|
+
- `Optional[X]` is unwrapped to `X`.
|
|
152
|
+
- Default values are pre-filled into widgets automatically.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Output & Logging
|
|
157
|
+
|
|
158
|
+
Tool methods can use `print()` and the standard `logging` module. Both are captured and rendered in the output console with colour coding:
|
|
159
|
+
|
|
160
|
+
| Source | Colour |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `print` / stdout | White |
|
|
163
|
+
| `logging.DEBUG` | Gray |
|
|
164
|
+
| `logging.INFO` | Cyan |
|
|
165
|
+
| `logging.WARNING` | Yellow |
|
|
166
|
+
| `logging.ERROR` | Red |
|
|
167
|
+
| `logging.CRITICAL` | Bold Red |
|
|
168
|
+
|
|
169
|
+
Return values from tool methods are **not** displayed in the GUI. Use `logging` or `print` for any output you want users to see.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Tool Page Buttons
|
|
174
|
+
|
|
175
|
+
| Button | Action |
|
|
176
|
+
|---|---|
|
|
177
|
+
| **Run** | Type-coerce parameters, run the method in a background thread. |
|
|
178
|
+
| **Reset** | Expand the parameter panel and clear the output console. Parameters are kept. |
|
|
179
|
+
| **Stop** | Request cancellation of the running task. |
|
|
180
|
+
| **Replay** | Open the History panel pre-filtered to this tool's past runs. |
|
|
181
|
+
| **Copy** | Copy current console output to clipboard. |
|
|
182
|
+
| **View Log** | Open the current console output in a resizable log viewer window. |
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Execution History
|
|
187
|
+
|
|
188
|
+
Every run is stored in SQLite. The History panel (sidebar button) shows:
|
|
189
|
+
|
|
190
|
+
- Timestamp, tool name, status badge, duration
|
|
191
|
+
- Per-row checkboxes with **Select All / Deselect All / Delete Selected**
|
|
192
|
+
- Filter by tool, status, and time range
|
|
193
|
+
- Click any row to see the parameter snapshot
|
|
194
|
+
- **Replay Params** — restores that run's parameters to the tool's form
|
|
195
|
+
- **View Full Log** — opens the full log in a resizable window with level filters and search
|
|
196
|
+
|
|
197
|
+
History is stored at `~/.decoui/history.db` by default. Override with `db_path` in `gui_main()`.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Example
|
|
202
|
+
|
|
203
|
+
See [`src/decoui/example.py`](src/decoui/example.py) for a complete demo covering all supported widget types.
|
|
204
|
+
|
|
205
|
+
Run it with:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
uv run python main.py
|
|
209
|
+
# or
|
|
210
|
+
python main.py
|
|
211
|
+
```
|
decoui-0.1.0/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# decoui
|
|
2
|
+
|
|
3
|
+
Decorator-driven GUI framework for Python. Annotate your methods — decoui generates a full PySide6 desktop app automatically.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Zero UI code** — decorate a class and its methods, call `gui_main()`
|
|
12
|
+
- **Native type mapping** — `str`, `int`, `float`, `bool`, `list`, `dict`, `Enum` → widgets automatically
|
|
13
|
+
- **Async execution** — every tool runs in a thread; stdout and `logging` are captured in real time
|
|
14
|
+
- **Execution history** — every run is persisted to SQLite with parameters, logs, and status
|
|
15
|
+
- **Replay** — restore any past run's parameters with one click
|
|
16
|
+
- **Light theme** — clean built-in stylesheet, Consolas / 微软雅黑 / Meiryo font stack
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install decoui
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Requires Python 3.10+ and PySide6 6.6+.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import logging
|
|
34
|
+
from decoui import tool, toolset, gui_main
|
|
35
|
+
|
|
36
|
+
@toolset(label="Text Tools", tags=["text"])
|
|
37
|
+
class TextTools:
|
|
38
|
+
|
|
39
|
+
@tool(label="Count Characters",
|
|
40
|
+
description="Count chars, words and lines.",
|
|
41
|
+
placeholders={"content": "Paste text here…"})
|
|
42
|
+
def count(self, content: str = "") -> str:
|
|
43
|
+
words = len(content.split())
|
|
44
|
+
logging.info("words=%d", words)
|
|
45
|
+
return f"{len(content)} chars / {words} words"
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
gui_main(title="My Tools")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`gui_main()` auto-discovers every `@toolset` class in the caller's global scope — no explicit registration needed.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## API Reference
|
|
56
|
+
|
|
57
|
+
### `@toolset`
|
|
58
|
+
|
|
59
|
+
Applied to a class. Groups its `@tool` methods under one sidebar entry.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
@toolset(
|
|
63
|
+
label="CSV Tools", # required — sidebar display name
|
|
64
|
+
tags=["file", "batch"], # optional — used by the tag filter bar
|
|
65
|
+
description="...", # optional — tooltip on hover in the sidebar
|
|
66
|
+
)
|
|
67
|
+
class CsvTools:
|
|
68
|
+
...
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| Parameter | Type | Description |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `label` | `str` | Required. Display name in the sidebar. |
|
|
74
|
+
| `tags` | `list[str]` | Tag filter bar labels. Multiple tags = AND filter. |
|
|
75
|
+
| `description` | `str` | Shown as a tooltip when hovering the toolset in the nav tree. |
|
|
76
|
+
|
|
77
|
+
### `@tool`
|
|
78
|
+
|
|
79
|
+
Applied to a method inside a `@toolset` class.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
@tool(
|
|
83
|
+
label="Merge Files",
|
|
84
|
+
description="Merge multiple files into one.",
|
|
85
|
+
placeholders={"files": "one path per line"},
|
|
86
|
+
confirm=True, # show confirmation dialog before running
|
|
87
|
+
timeout=120, # cancel after N seconds (None = unlimited)
|
|
88
|
+
)
|
|
89
|
+
def merge(self, files: list, output: str = "out.txt") -> str:
|
|
90
|
+
...
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
| Parameter | Type | Default | Description |
|
|
94
|
+
|---|---|---|---|
|
|
95
|
+
| `label` | `str` | required | Tool display name. |
|
|
96
|
+
| `description` | `str` | `""` | Shown in a bordered box below the title. |
|
|
97
|
+
| `placeholders` | `dict[str,str]` | `{}` | Placeholder text per parameter name. |
|
|
98
|
+
| `confirm` | `bool` | `False` | Show a Yes/No confirmation dialog before running. |
|
|
99
|
+
| `timeout` | `int\|None` | `None` | Execution timeout in seconds. |
|
|
100
|
+
|
|
101
|
+
### `gui_main`
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
gui_main(title="My App", db_path="~/.myapp/history.db")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Parameter | Type | Default | Description |
|
|
108
|
+
|---|---|---|---|
|
|
109
|
+
| `title` | `str` | `"decoui"` | Window title. |
|
|
110
|
+
| `db_path` | `str\|Path\|None` | `~/.decoui/history.db` | SQLite database path for execution history. |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Type → Widget Mapping
|
|
115
|
+
|
|
116
|
+
| Python annotation | Widget | Notes |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| `str` | `QLineEdit` | Single-line text. |
|
|
119
|
+
| `int` | `QSpinBox` | Integer, full int range. |
|
|
120
|
+
| `float` | `QDoubleSpinBox` | 4 decimal places. |
|
|
121
|
+
| `bool` | `QCheckBox` | Checked / unchecked. |
|
|
122
|
+
| `list` | `QTextEdit` | One item per line or comma-separated. |
|
|
123
|
+
| `dict` | `QTextEdit` | JSON input; parsed with `json.loads` then `ast.literal_eval`. Raises on invalid input. |
|
|
124
|
+
| `Enum` subclass | `QComboBox` | Dropdown of enum members. |
|
|
125
|
+
|
|
126
|
+
- Required parameters (no default) are marked with a red `*` in the form label.
|
|
127
|
+
- `Optional[X]` is unwrapped to `X`.
|
|
128
|
+
- Default values are pre-filled into widgets automatically.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Output & Logging
|
|
133
|
+
|
|
134
|
+
Tool methods can use `print()` and the standard `logging` module. Both are captured and rendered in the output console with colour coding:
|
|
135
|
+
|
|
136
|
+
| Source | Colour |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `print` / stdout | White |
|
|
139
|
+
| `logging.DEBUG` | Gray |
|
|
140
|
+
| `logging.INFO` | Cyan |
|
|
141
|
+
| `logging.WARNING` | Yellow |
|
|
142
|
+
| `logging.ERROR` | Red |
|
|
143
|
+
| `logging.CRITICAL` | Bold Red |
|
|
144
|
+
|
|
145
|
+
Return values from tool methods are **not** displayed in the GUI. Use `logging` or `print` for any output you want users to see.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Tool Page Buttons
|
|
150
|
+
|
|
151
|
+
| Button | Action |
|
|
152
|
+
|---|---|
|
|
153
|
+
| **Run** | Type-coerce parameters, run the method in a background thread. |
|
|
154
|
+
| **Reset** | Expand the parameter panel and clear the output console. Parameters are kept. |
|
|
155
|
+
| **Stop** | Request cancellation of the running task. |
|
|
156
|
+
| **Replay** | Open the History panel pre-filtered to this tool's past runs. |
|
|
157
|
+
| **Copy** | Copy current console output to clipboard. |
|
|
158
|
+
| **View Log** | Open the current console output in a resizable log viewer window. |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Execution History
|
|
163
|
+
|
|
164
|
+
Every run is stored in SQLite. The History panel (sidebar button) shows:
|
|
165
|
+
|
|
166
|
+
- Timestamp, tool name, status badge, duration
|
|
167
|
+
- Per-row checkboxes with **Select All / Deselect All / Delete Selected**
|
|
168
|
+
- Filter by tool, status, and time range
|
|
169
|
+
- Click any row to see the parameter snapshot
|
|
170
|
+
- **Replay Params** — restores that run's parameters to the tool's form
|
|
171
|
+
- **View Full Log** — opens the full log in a resizable window with level filters and search
|
|
172
|
+
|
|
173
|
+
History is stored at `~/.decoui/history.db` by default. Override with `db_path` in `gui_main()`.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Example
|
|
178
|
+
|
|
179
|
+
See [`src/decoui/example.py`](src/decoui/example.py) for a complete demo covering all supported widget types.
|
|
180
|
+
|
|
181
|
+
Run it with:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
uv run python main.py
|
|
185
|
+
# or
|
|
186
|
+
python main.py
|
|
187
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "decoui"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Decorator-driven GUI framework for Python — generate PySide6 UIs from type annotations"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
keywords = ["gui", "decorator", "pyside6", "qt", "ui", "framework"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.10",
|
|
15
|
+
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Topic :: Software Development :: User Interfaces",
|
|
19
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"PySide6>=6.6.0",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/luvmagi/decoui"
|
|
27
|
+
Repository = "https://github.com/luvmagi/decoui"
|
|
28
|
+
Issues = "https://github.com/luvmagi/decoui/issues"
|
|
29
|
+
|
|
30
|
+
[build-system]
|
|
31
|
+
requires = ["hatchling"]
|
|
32
|
+
build-backend = "hatchling.build"
|
|
33
|
+
|
|
34
|
+
[tool.hatch.build.targets.wheel]
|
|
35
|
+
packages = ["src/decoui"]
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel.shared-data]
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.sdist]
|
|
40
|
+
include = ["src/decoui/icon.png"]
|
|
41
|
+
|
|
42
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
43
|
+
"src/decoui/icon.png" = "decoui/icon.png"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = [
|
|
47
|
+
"pytest>=8.0",
|
|
48
|
+
"twine>=5.0",
|
|
49
|
+
]
|
|
Binary file
|