simpleui-py 1.0.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.
- simpleui_py-1.0.0/LICENSE +21 -0
- simpleui_py-1.0.0/MANIFEST.in +9 -0
- simpleui_py-1.0.0/PKG-INFO +54 -0
- simpleui_py-1.0.0/README.md +30 -0
- simpleui_py-1.0.0/pyproject.toml +43 -0
- simpleui_py-1.0.0/setup.cfg +4 -0
- simpleui_py-1.0.0/simpleui/__init__.py +73 -0
- simpleui_py-1.0.0/simpleui/components/__init__.py +28 -0
- simpleui_py-1.0.0/simpleui/components/alert.py +168 -0
- simpleui_py-1.0.0/simpleui/components/button.py +259 -0
- simpleui_py-1.0.0/simpleui/components/card.py +130 -0
- simpleui_py-1.0.0/simpleui/components/input.py +264 -0
- simpleui_py-1.0.0/simpleui/components/layout.py +174 -0
- simpleui_py-1.0.0/simpleui/components/progress.py +168 -0
- simpleui_py-1.0.0/simpleui/components/switch.py +91 -0
- simpleui_py-1.0.0/simpleui/components/tag.py +121 -0
- simpleui_py-1.0.0/simpleui/core.py +1055 -0
- simpleui_py-1.0.0/simpleui/py.typed +1 -0
- simpleui_py-1.0.0/simpleui/utils.py +184 -0
- simpleui_py-1.0.0/simpleui_py.egg-info/PKG-INFO +54 -0
- simpleui_py-1.0.0/simpleui_py.egg-info/SOURCES.txt +23 -0
- simpleui_py-1.0.0/simpleui_py.egg-info/dependency_links.txt +1 -0
- simpleui_py-1.0.0/simpleui_py.egg-info/entry_points.txt +2 -0
- simpleui_py-1.0.0/simpleui_py.egg-info/requires.txt +3 -0
- simpleui_py-1.0.0/simpleui_py.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SimpleUI Team
|
|
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,54 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simpleui-py
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Fluent风格Python UI组件库 - 简约设计,无限可能
|
|
5
|
+
Author-email: SimpleUI Team <hello@simpleui.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/simpleui/simpleui-py
|
|
8
|
+
Keywords: ui,components,fluent,web,html
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
\# SimpleUI Python
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<div align="center">
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
\*\*Fluent 风格 Python UI 组件库\*\*
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
简约设计,无限可能
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
\---
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
\## 安装
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "simpleui-py"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Fluent风格Python UI组件库 - 简约设计,无限可能"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "SimpleUI Team", email = "hello@simpleui.dev"}
|
|
13
|
+
]
|
|
14
|
+
keywords = ["ui", "components", "fluent", "web", "html"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13"
|
|
25
|
+
]
|
|
26
|
+
requires-python = ">=3.8"
|
|
27
|
+
dependencies = []
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = ["pytest>=7.0"]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/simpleui/simpleui-py"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
simpleui = "simpleui:demo"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["."]
|
|
40
|
+
include = ["simpleui*"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.package-data]
|
|
43
|
+
simpleui = ["py.typed"]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SimpleUI - Fluent 风格 Python UI 组件库
|
|
3
|
+
简约设计,无限可能
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "1.0.0"
|
|
7
|
+
__author__ = "SimpleUI Team"
|
|
8
|
+
|
|
9
|
+
# 从 core 导入核心功能
|
|
10
|
+
from .core import (
|
|
11
|
+
Component,
|
|
12
|
+
Theme,
|
|
13
|
+
ThemeType,
|
|
14
|
+
render_html,
|
|
15
|
+
export_html,
|
|
16
|
+
set_theme,
|
|
17
|
+
get_theme,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# 从 components 导入所有组件
|
|
21
|
+
from .components import (
|
|
22
|
+
Button,
|
|
23
|
+
ButtonGroup,
|
|
24
|
+
Input,
|
|
25
|
+
TextArea,
|
|
26
|
+
Card,
|
|
27
|
+
Switch,
|
|
28
|
+
Tag,
|
|
29
|
+
Progress,
|
|
30
|
+
Alert,
|
|
31
|
+
Container,
|
|
32
|
+
Row,
|
|
33
|
+
Column,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# 从 utils 导入工具函数
|
|
37
|
+
from .utils import preview, serve, demo, playground
|
|
38
|
+
|
|
39
|
+
# 导出列表
|
|
40
|
+
__all__ = [
|
|
41
|
+
# 版本信息
|
|
42
|
+
"__version__",
|
|
43
|
+
"__author__",
|
|
44
|
+
|
|
45
|
+
# 核心类
|
|
46
|
+
"Component",
|
|
47
|
+
"Theme",
|
|
48
|
+
"ThemeType",
|
|
49
|
+
"render_html",
|
|
50
|
+
"export_html",
|
|
51
|
+
"set_theme",
|
|
52
|
+
"get_theme",
|
|
53
|
+
|
|
54
|
+
# 组件
|
|
55
|
+
"Button",
|
|
56
|
+
"ButtonGroup",
|
|
57
|
+
"Input",
|
|
58
|
+
"TextArea",
|
|
59
|
+
"Card",
|
|
60
|
+
"Switch",
|
|
61
|
+
"Tag",
|
|
62
|
+
"Progress",
|
|
63
|
+
"Alert",
|
|
64
|
+
"Container",
|
|
65
|
+
"Row",
|
|
66
|
+
"Column",
|
|
67
|
+
|
|
68
|
+
# 工具函数
|
|
69
|
+
"preview",
|
|
70
|
+
"serve",
|
|
71
|
+
"demo",
|
|
72
|
+
"playground",
|
|
73
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SimpleUI 组件模块
|
|
3
|
+
导出所有 UI 组件
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .button import Button, ButtonGroup
|
|
7
|
+
from .input import Input, TextArea
|
|
8
|
+
from .card import Card
|
|
9
|
+
from .switch import Switch
|
|
10
|
+
from .tag import Tag
|
|
11
|
+
from .progress import Progress
|
|
12
|
+
from .alert import Alert
|
|
13
|
+
from .layout import Container, Row, Column
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"Button",
|
|
17
|
+
"ButtonGroup",
|
|
18
|
+
"Input",
|
|
19
|
+
"TextArea",
|
|
20
|
+
"Card",
|
|
21
|
+
"Switch",
|
|
22
|
+
"Tag",
|
|
23
|
+
"Progress",
|
|
24
|
+
"Alert",
|
|
25
|
+
"Container",
|
|
26
|
+
"Row",
|
|
27
|
+
"Column",
|
|
28
|
+
]
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""
|
|
2
|
+
进度条组件
|
|
3
|
+
Fluent 风格进度条,支持多种状态
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import Optional, Literal
|
|
7
|
+
from ..core import Component
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Progress(Component):
|
|
11
|
+
"""
|
|
12
|
+
Fluent 风格进度条组件
|
|
13
|
+
|
|
14
|
+
支持线性进度条和圆形进度条,支持多种状态颜色。
|
|
15
|
+
|
|
16
|
+
参数:
|
|
17
|
+
value: 当前进度值 (0-100)
|
|
18
|
+
max_value: 最大值
|
|
19
|
+
label: 标签文本
|
|
20
|
+
show_value: 是否显示数值
|
|
21
|
+
status: 状态颜色
|
|
22
|
+
striped: 是否显示条纹
|
|
23
|
+
height: 高度
|
|
24
|
+
|
|
25
|
+
示例:
|
|
26
|
+
Progress(value=75, label="下载进度")
|
|
27
|
+
Progress(value=100, status="success")
|
|
28
|
+
Progress.circle(value=70)
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
# 状态对应的CSS类
|
|
32
|
+
STATUS_CLASSES = {
|
|
33
|
+
"default": "",
|
|
34
|
+
"success": "sui-progress-success",
|
|
35
|
+
"warning": "sui-progress-warning",
|
|
36
|
+
"danger": "sui-progress-danger",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
value: float = 0,
|
|
42
|
+
max_value: float = 100,
|
|
43
|
+
label: Optional[str] = None,
|
|
44
|
+
show_value: bool = True,
|
|
45
|
+
status: Literal["default", "success", "warning", "danger"] = "default",
|
|
46
|
+
striped: bool = False,
|
|
47
|
+
animated: bool = False,
|
|
48
|
+
height: str = "8px",
|
|
49
|
+
**kwargs
|
|
50
|
+
):
|
|
51
|
+
super().__init__(**kwargs)
|
|
52
|
+
self._max_value = max_value
|
|
53
|
+
self.value = max(0, min(value, self._max_value))
|
|
54
|
+
self.label = label
|
|
55
|
+
self.show_value = show_value
|
|
56
|
+
self.status = status
|
|
57
|
+
self.striped = striped
|
|
58
|
+
self.animated = animated
|
|
59
|
+
self.height = height
|
|
60
|
+
|
|
61
|
+
def _get_progress_classes(self) -> str:
|
|
62
|
+
"""获取进度条CSS类"""
|
|
63
|
+
classes = ["sui-progress"]
|
|
64
|
+
|
|
65
|
+
if self.status in self.STATUS_CLASSES:
|
|
66
|
+
classes.append(self.STATUS_CLASSES[self.status])
|
|
67
|
+
|
|
68
|
+
return " ".join(classes)
|
|
69
|
+
|
|
70
|
+
def _get_percentage(self) -> float:
|
|
71
|
+
"""计算百分比"""
|
|
72
|
+
if self._max_value == 0:
|
|
73
|
+
return 0
|
|
74
|
+
return (self.value / self._max_value) * 100
|
|
75
|
+
|
|
76
|
+
def render(self) -> str:
|
|
77
|
+
"""渲染进度条"""
|
|
78
|
+
html_parts = ['<div class="sui-progress-wrapper">']
|
|
79
|
+
|
|
80
|
+
# 标签和数值
|
|
81
|
+
if self.label or self.show_value:
|
|
82
|
+
html_parts.append('<div class="sui-progress-label">')
|
|
83
|
+
|
|
84
|
+
if self.label:
|
|
85
|
+
html_parts.append(f'<span>{self.label}</span>')
|
|
86
|
+
else:
|
|
87
|
+
html_parts.append('<span></span>')
|
|
88
|
+
|
|
89
|
+
if self.show_value:
|
|
90
|
+
html_parts.append(f'<span>{round(self._get_percentage())}%</span>')
|
|
91
|
+
|
|
92
|
+
html_parts.append('</div>')
|
|
93
|
+
|
|
94
|
+
# 进度条
|
|
95
|
+
percentage = self._get_percentage()
|
|
96
|
+
html_parts.append(f'<div class="{self._get_progress_classes()}" style="height:{self.height}">')
|
|
97
|
+
|
|
98
|
+
bar_style = f"width:{percentage}%"
|
|
99
|
+
if self.striped:
|
|
100
|
+
bar_style += ";background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-size: 1rem 1rem"
|
|
101
|
+
|
|
102
|
+
html_parts.append(f'<div class="sui-progress-bar" style="{bar_style}"></div>')
|
|
103
|
+
html_parts.append('</div>')
|
|
104
|
+
|
|
105
|
+
html_parts.append('</div>')
|
|
106
|
+
|
|
107
|
+
return "".join(html_parts)
|
|
108
|
+
|
|
109
|
+
def set_value(self, value: float) -> "Progress":
|
|
110
|
+
"""设置当前值"""
|
|
111
|
+
self.value = max(0, min(value, self._max_value))
|
|
112
|
+
return self
|
|
113
|
+
|
|
114
|
+
def set_status(self, status: Literal["default", "success", "warning", "danger"]) -> "Progress":
|
|
115
|
+
"""设置状态"""
|
|
116
|
+
self.status = status
|
|
117
|
+
return self
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def circle(
|
|
121
|
+
value: float = 0,
|
|
122
|
+
max_value: float = 100,
|
|
123
|
+
size: int = 80,
|
|
124
|
+
stroke_width: int = 6,
|
|
125
|
+
status: Literal["default", "success", "warning", "danger"] = "default",
|
|
126
|
+
) -> str:
|
|
127
|
+
"""
|
|
128
|
+
创建圆形进度条
|
|
129
|
+
|
|
130
|
+
参数:
|
|
131
|
+
value: 当前进度值
|
|
132
|
+
max_value: 最大值
|
|
133
|
+
size: 尺寸
|
|
134
|
+
stroke_width: 线条宽度
|
|
135
|
+
status: 状态
|
|
136
|
+
|
|
137
|
+
返回:
|
|
138
|
+
HTML字符串
|
|
139
|
+
"""
|
|
140
|
+
percentage = (value / max_value) * 100 if max_value > 0 else 0
|
|
141
|
+
radius = (size - stroke_width) / 2
|
|
142
|
+
circumference = 2 * 3.14159 * radius
|
|
143
|
+
stroke_dashoffset = circumference * (1 - percentage / 100)
|
|
144
|
+
|
|
145
|
+
colors = {
|
|
146
|
+
"default": "url(#progress-gradient)",
|
|
147
|
+
"success": "#43e97b",
|
|
148
|
+
"warning": "#fbbf24",
|
|
149
|
+
"danger": "#ef4444",
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
color = colors.get(status, colors["default"])
|
|
153
|
+
|
|
154
|
+
return f'''
|
|
155
|
+
<div class="sui-progress-circle" style="width:{size}px;height:{size}px;position:relative">
|
|
156
|
+
<svg width="{size}" height="{size}" style="transform:rotate(-90deg)">
|
|
157
|
+
<defs>
|
|
158
|
+
<linearGradient id="progress-gradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
159
|
+
<stop offset="0%" stop-color="#667eea"/>
|
|
160
|
+
<stop offset="100%" stop-color="#764ba2"/>
|
|
161
|
+
</linearGradient>
|
|
162
|
+
</defs>
|
|
163
|
+
<circle cx="{size/2}" cy="{size/2}" r="{radius}" fill="none" stroke="var(--bg-card)" stroke-width="{stroke_width}"/>
|
|
164
|
+
<circle cx="{size/2}" cy="{size/2}" r="{radius}" fill="none" stroke="{color}" stroke-width="{stroke_width}" stroke-linecap="round" stroke-dasharray="{circumference}" stroke-dashoffset="{stroke_dashoffset}" style="transition:stroke-dashoffset 0.5s ease"/>
|
|
165
|
+
</svg>
|
|
166
|
+
<span style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;color:var(--text-primary)">{round(percentage)}%</span>
|
|
167
|
+
</div>
|
|
168
|
+
'''
|