streamlit-toggle-diy 1.0.1__tar.gz → 1.1.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- streamlit_toggle_diy-1.1.3/MANIFEST.in +3 -0
- streamlit_toggle_diy-1.1.3/PKG-INFO +92 -0
- streamlit_toggle_diy-1.1.3/README.md +80 -0
- streamlit_toggle_diy-1.1.3/setup.py +30 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/__init__.py +295 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/asset-manifest.json +19 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/bootstrap.min.css +9501 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/index.html +1 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/precache-manifest.b7df6085566f07f8f27b94ee8ed2d302.js +22 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/service-worker.js +39 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/static/js/2.9720bf9e.chunk.js +3 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/static/js/2.9720bf9e.chunk.js.LICENSE.txt +68 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/static/js/2.9720bf9e.chunk.js.map +1 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/static/js/main.9f3c3eed.chunk.js +2 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/static/js/main.9f3c3eed.chunk.js.map +1 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/static/js/runtime-main.cc20bba3.js +2 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/build/static/js/runtime-main.cc20bba3.js.map +1 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/public/bootstrap.min.css +9501 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/public/index.html +25 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/src/index.tsx +11 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/src/react-app-env.d.ts +1 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/src/streamlit_toggle.tsx +170 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy/frontend/src/style.css +6 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy.egg-info/PKG-INFO +92 -0
- streamlit_toggle_diy-1.1.3/streamlit_toggle_diy.egg-info/SOURCES.txt +28 -0
- streamlit_toggle_diy-1.0.1/MANIFEST.in +0 -1
- streamlit_toggle_diy-1.0.1/PKG-INFO +0 -10
- streamlit_toggle_diy-1.0.1/README.md +0 -29
- streamlit_toggle_diy-1.0.1/setup.py +0 -20
- streamlit_toggle_diy-1.0.1/streamlit_toggle_diy/__init__.py +0 -140
- streamlit_toggle_diy-1.0.1/streamlit_toggle_diy.egg-info/PKG-INFO +0 -10
- streamlit_toggle_diy-1.0.1/streamlit_toggle_diy.egg-info/SOURCES.txt +0 -10
- {streamlit_toggle_diy-1.0.1 → streamlit_toggle_diy-1.1.3}/LICENSE +0 -0
- {streamlit_toggle_diy-1.0.1 → streamlit_toggle_diy-1.1.3}/setup.cfg +0 -0
- {streamlit_toggle_diy-1.0.1 → streamlit_toggle_diy-1.1.3}/streamlit_toggle_diy.egg-info/dependency_links.txt +0 -0
- {streamlit_toggle_diy-1.0.1 → streamlit_toggle_diy-1.1.3}/streamlit_toggle_diy.egg-info/requires.txt +0 -0
- {streamlit_toggle_diy-1.0.1 → streamlit_toggle_diy-1.1.3}/streamlit_toggle_diy.egg-info/top_level.txt +0 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: streamlit_toggle_diy
|
3
|
+
Version: 1.1.3
|
4
|
+
Summary: A customized Streamlit toggle switch component with customizable labels, colors, and border radius
|
5
|
+
Home-page: https://github.com/flowing-water1/streamlit-toggle-switch-diy
|
6
|
+
Author: Flow Water
|
7
|
+
Author-email: 1665526933@qq.com
|
8
|
+
Requires-Python: >=3.6
|
9
|
+
Description-Content-Type: text/markdown
|
10
|
+
License-File: LICENSE
|
11
|
+
Requires-Dist: streamlit>=0.63
|
12
|
+
|
13
|
+
# streamlit_toggle_switch_diy
|
14
|
+
|
15
|
+
Creates a toggle switch with color and placement customizations, and you can change the label's color, radius, font size, and more.
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
## Function
|
20
|
+
|
21
|
+
- Customize label background color
|
22
|
+
- Customize the text color, font size, and font weight for both labels
|
23
|
+
- Customize the Switch size (small or medium)
|
24
|
+
- Customize the background color near the button
|
25
|
+
- Custom rounded corners
|
26
|
+
- Support multiple layout methods
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
```shell
|
31
|
+
pip install streamlit-toggle-switch-diy
|
32
|
+
```
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
```python
|
37
|
+
import streamlit as st
|
38
|
+
import streamlit_toggle_switch_diy as tog
|
39
|
+
|
40
|
+
tog.st_toggle_switch(
|
41
|
+
key=None,
|
42
|
+
label_start="111",
|
43
|
+
label_end="",
|
44
|
+
justify='flex-start',
|
45
|
+
default_value=False,
|
46
|
+
inactive_color='#D3D3D3',
|
47
|
+
active_color="#11567f",
|
48
|
+
track_color="#29B5E8",
|
49
|
+
label_bg_color_start=None,
|
50
|
+
label_bg_color_end=None,
|
51
|
+
background_color_near_button_start=None,
|
52
|
+
background_color_near_button_end=None,
|
53
|
+
border_radius=None,
|
54
|
+
)
|
55
|
+
```
|
56
|
+
|
57
|
+
|
58
|
+
## Parameters
|
59
|
+
|
60
|
+
|
61
|
+
| **Parameter Name** | **Type** | **Default** | **Description** |
|
62
|
+
| ------------------------------------------ | ------------------------------------ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
63
|
+
| **key** | `str` | None | The unique identifier for each component instance.<br />Used to distinguish different component instances in the Streamlit application. |
|
64
|
+
| **label\_start** | `str` | `""` | The text content of the label before the switch. If a preceding label is not needed, pass an empty string`""`. |
|
65
|
+
| **label\_end** | `str` | `""` | The text content of the label after the switch. If a following label is not needed, pass an empty string`""`. |
|
66
|
+
| **justify** | `{'flex-start','center','flex-end'}` | `'flex-start'` | Controls alignment of labels and the switch within the container. |
|
67
|
+
| **default\_value** | `bool` | `False` | The initial state of the toggle switch.`True`= On,`False`= Off. |
|
68
|
+
| **inactive\_color** | `str` | `'#D3D3D3'` | The color of the slider when the switch is inactive (off). |
|
69
|
+
| **active\_color** | `str` | `'#11567f'` | The color of the slider when the switch is active (on). |
|
70
|
+
| **track\_color** | `str` | `'#29B5E8'` | The color of the switch track (background). |
|
71
|
+
| **label\_bg\_color\_start** | `str` | `None` | The starting value of the label background color, used to create a gradient effect. |
|
72
|
+
| **label\_bg\_color\_end** | `str` | `None` | The ending value of the label background color, used to create a gradient effect. |
|
73
|
+
| **background\_color\_near\_button\_start** | `str` | `None` | The starting value of the background color near the switch, used to create a gradient effect behind the component. |
|
74
|
+
| **background\_color\_near\_button\_end** | `str` | `None` | The ending value of the background color near the switch, used to create a gradient effect behind the component. |
|
75
|
+
| **border\_radius** | `str` | `None` | The border-radius of the component, such as`'4px'`,`'8px'`,`'50%'`, etc. |
|
76
|
+
| **label\_start\_color** | `str` | `"#7f1916"` | Text color for the left (start) label. |
|
77
|
+
| **label\_end\_color** | `str` | `"#FFFFFF"` | Text color for the right (end) label. |
|
78
|
+
| **label\_font\_size** | `str` | `"14px"` | Font size for both labels (e.g.`"14px"`,`"12pt"`). |
|
79
|
+
| **label\_font\_weight** | `str` | `"bold"` | Font weight for both labels (e.g.`"bold"`,`"normal"`,`"500"`). |
|
80
|
+
| **switch\_size** | `{'small','medium'}` | `"medium"` | The size of the Switch component. |
|
81
|
+
|
82
|
+
> **Note**:
|
83
|
+
>
|
84
|
+
> * If both `label_bg_color_start` and `label_bg_color_end` are set, a gradient background for the label(s) will be created.
|
85
|
+
> * If both `background_color_near_button_start` and `background_color_near_button_end` are provided, a gradient behind the switch is created.
|
86
|
+
> * If you only provide one color, it will be used as a solid background.
|
87
|
+
> * `label_start_color` and `label_end_color` control the text color of labels, while `label_bg_color_start` and `label_bg_color_end` control the background of those labels.
|
88
|
+
>
|
89
|
+
|
90
|
+
## Operation
|
91
|
+
|
92
|
+
![streamlit.gif](assets/streamlit.gif)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# streamlit_toggle_switch_diy
|
2
|
+
|
3
|
+
Creates a toggle switch with color and placement customizations, and you can change the label's color, radius, font size, and more.
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
## Function
|
8
|
+
|
9
|
+
- Customize label background color
|
10
|
+
- Customize the text color, font size, and font weight for both labels
|
11
|
+
- Customize the Switch size (small or medium)
|
12
|
+
- Customize the background color near the button
|
13
|
+
- Custom rounded corners
|
14
|
+
- Support multiple layout methods
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
```shell
|
19
|
+
pip install streamlit-toggle-switch-diy
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```python
|
25
|
+
import streamlit as st
|
26
|
+
import streamlit_toggle_switch_diy as tog
|
27
|
+
|
28
|
+
tog.st_toggle_switch(
|
29
|
+
key=None,
|
30
|
+
label_start="111",
|
31
|
+
label_end="",
|
32
|
+
justify='flex-start',
|
33
|
+
default_value=False,
|
34
|
+
inactive_color='#D3D3D3',
|
35
|
+
active_color="#11567f",
|
36
|
+
track_color="#29B5E8",
|
37
|
+
label_bg_color_start=None,
|
38
|
+
label_bg_color_end=None,
|
39
|
+
background_color_near_button_start=None,
|
40
|
+
background_color_near_button_end=None,
|
41
|
+
border_radius=None,
|
42
|
+
)
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
## Parameters
|
47
|
+
|
48
|
+
|
49
|
+
| **Parameter Name** | **Type** | **Default** | **Description** |
|
50
|
+
| ------------------------------------------ | ------------------------------------ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
51
|
+
| **key** | `str` | None | The unique identifier for each component instance.<br />Used to distinguish different component instances in the Streamlit application. |
|
52
|
+
| **label\_start** | `str` | `""` | The text content of the label before the switch. If a preceding label is not needed, pass an empty string`""`. |
|
53
|
+
| **label\_end** | `str` | `""` | The text content of the label after the switch. If a following label is not needed, pass an empty string`""`. |
|
54
|
+
| **justify** | `{'flex-start','center','flex-end'}` | `'flex-start'` | Controls alignment of labels and the switch within the container. |
|
55
|
+
| **default\_value** | `bool` | `False` | The initial state of the toggle switch.`True`= On,`False`= Off. |
|
56
|
+
| **inactive\_color** | `str` | `'#D3D3D3'` | The color of the slider when the switch is inactive (off). |
|
57
|
+
| **active\_color** | `str` | `'#11567f'` | The color of the slider when the switch is active (on). |
|
58
|
+
| **track\_color** | `str` | `'#29B5E8'` | The color of the switch track (background). |
|
59
|
+
| **label\_bg\_color\_start** | `str` | `None` | The starting value of the label background color, used to create a gradient effect. |
|
60
|
+
| **label\_bg\_color\_end** | `str` | `None` | The ending value of the label background color, used to create a gradient effect. |
|
61
|
+
| **background\_color\_near\_button\_start** | `str` | `None` | The starting value of the background color near the switch, used to create a gradient effect behind the component. |
|
62
|
+
| **background\_color\_near\_button\_end** | `str` | `None` | The ending value of the background color near the switch, used to create a gradient effect behind the component. |
|
63
|
+
| **border\_radius** | `str` | `None` | The border-radius of the component, such as`'4px'`,`'8px'`,`'50%'`, etc. |
|
64
|
+
| **label\_start\_color** | `str` | `"#7f1916"` | Text color for the left (start) label. |
|
65
|
+
| **label\_end\_color** | `str` | `"#FFFFFF"` | Text color for the right (end) label. |
|
66
|
+
| **label\_font\_size** | `str` | `"14px"` | Font size for both labels (e.g.`"14px"`,`"12pt"`). |
|
67
|
+
| **label\_font\_weight** | `str` | `"bold"` | Font weight for both labels (e.g.`"bold"`,`"normal"`,`"500"`). |
|
68
|
+
| **switch\_size** | `{'small','medium'}` | `"medium"` | The size of the Switch component. |
|
69
|
+
|
70
|
+
> **Note**:
|
71
|
+
>
|
72
|
+
> * If both `label_bg_color_start` and `label_bg_color_end` are set, a gradient background for the label(s) will be created.
|
73
|
+
> * If both `background_color_near_button_start` and `background_color_near_button_end` are provided, a gradient behind the switch is created.
|
74
|
+
> * If you only provide one color, it will be used as a solid background.
|
75
|
+
> * `label_start_color` and `label_end_color` control the text color of labels, while `label_bg_color_start` and `label_bg_color_end` control the background of those labels.
|
76
|
+
>
|
77
|
+
|
78
|
+
## Operation
|
79
|
+
|
80
|
+
![streamlit.gif](assets/streamlit.gif)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import setuptools
|
2
|
+
import os
|
3
|
+
|
4
|
+
# 读取 README.md 内容
|
5
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
6
|
+
long_description = fh.read()
|
7
|
+
|
8
|
+
setuptools.setup(
|
9
|
+
name="streamlit_toggle_diy",
|
10
|
+
version="1.1.3",
|
11
|
+
author="Flow Water",
|
12
|
+
author_email="1665526933@qq.com",
|
13
|
+
description="A customized Streamlit toggle switch component with customizable labels, colors, and border radius",
|
14
|
+
long_description=long_description, # 设置长描述
|
15
|
+
long_description_content_type="text/markdown", # 指定内容类型为 Markdown
|
16
|
+
url="https://github.com/flowing-water1/streamlit-toggle-switch-diy",
|
17
|
+
packages=setuptools.find_packages(),
|
18
|
+
include_package_data=True,
|
19
|
+
package_data={
|
20
|
+
"streamlit_toggle_diy": [
|
21
|
+
"frontend/build/**/*",
|
22
|
+
"frontend/public/**/*",
|
23
|
+
],
|
24
|
+
},
|
25
|
+
classifiers=[],
|
26
|
+
python_requires=">=3.6",
|
27
|
+
install_requires=[
|
28
|
+
"streamlit >= 0.63",
|
29
|
+
],
|
30
|
+
)
|
@@ -0,0 +1,295 @@
|
|
1
|
+
import os
|
2
|
+
import streamlit.components.v1 as components
|
3
|
+
import streamlit as st
|
4
|
+
|
5
|
+
_RELEASE = True
|
6
|
+
|
7
|
+
if not _RELEASE:
|
8
|
+
_component_func = components.declare_component(
|
9
|
+
"streamlit_toggle_diy",
|
10
|
+
url="http://localhost:3001", # 本地开发时的地址
|
11
|
+
)
|
12
|
+
else:
|
13
|
+
parent_dir = os.path.dirname(os.path.abspath(__file__))
|
14
|
+
build_dir = os.path.join(parent_dir, "frontend/build")
|
15
|
+
_component_func = components.declare_component("streamlit_toggle_diy", path=build_dir)
|
16
|
+
|
17
|
+
|
18
|
+
def st_toggle_switch(
|
19
|
+
key=None,
|
20
|
+
label_start="", # 前标签文字
|
21
|
+
label_end="", # 后标签文字
|
22
|
+
justify='flex-start', # 对齐方式
|
23
|
+
default_value=False, # 默认开关状态
|
24
|
+
inactive_color='#CEE8FF',
|
25
|
+
active_color="#00668c",
|
26
|
+
track_color="#3D5A80",
|
27
|
+
label_bg_color_start="#FFFFFF",
|
28
|
+
label_bg_color_end="yellow",
|
29
|
+
background_color_near_button_start="#FFFFFF",
|
30
|
+
background_color_near_button_end="#FFFFFF",
|
31
|
+
border_radius='30px',
|
32
|
+
label_start_color="#333333",
|
33
|
+
label_end_color="red",
|
34
|
+
label_font_size="16px",
|
35
|
+
label_font_weight="bold",
|
36
|
+
switch_size="medium",
|
37
|
+
):
|
38
|
+
"""
|
39
|
+
在 Streamlit 中创建一个可自定义颜色、大小的切换开关组件。
|
40
|
+
|
41
|
+
Parameters
|
42
|
+
----------
|
43
|
+
key: str
|
44
|
+
组件在 session_state 中的 key,用于区分多个组件实例。
|
45
|
+
label_start: str
|
46
|
+
开关左侧标签文字。
|
47
|
+
label_end: str
|
48
|
+
开关右侧标签文字。
|
49
|
+
justify: {'flex-start', 'center', 'flex-end'}
|
50
|
+
标签和开关在容器中的对齐方式。
|
51
|
+
default_value: bool
|
52
|
+
开关的默认状态,True 为打开,False 为关闭。
|
53
|
+
inactive_color: str
|
54
|
+
开关未激活时的按钮颜色。
|
55
|
+
active_color: str
|
56
|
+
开关激活时的按钮颜色。
|
57
|
+
track_color: str
|
58
|
+
开关轨道(背景)的颜色。
|
59
|
+
label_bg_color_start: str
|
60
|
+
左 / 上方标签背景色(如果需要渐变,可与 label_bg_color_end 联合使用)。
|
61
|
+
label_bg_color_end: str
|
62
|
+
右 / 下方标签背景色(如果需要渐变,可与 label_bg_color_start 联合使用)。
|
63
|
+
background_color_near_button_start: str
|
64
|
+
开关附近背景的起始颜色(可配合 background_color_near_button_end 做渐变)。
|
65
|
+
background_color_near_button_end: str
|
66
|
+
开关附近背景的结束颜色(可配合 background_color_near_button_start 做渐变)。
|
67
|
+
border_radius: str
|
68
|
+
组件的圆角,如 '4px', '8px', '50%' 等。
|
69
|
+
|
70
|
+
label_start_color: str
|
71
|
+
前标签文字颜色(默认为 #7f1916)。
|
72
|
+
label_end_color: str
|
73
|
+
后标签文字颜色(默认为 #FFFFFF)。
|
74
|
+
label_font_size: str
|
75
|
+
标签文字的字体大小(如 '14px' 等)。
|
76
|
+
label_font_weight: str
|
77
|
+
标签文字的粗细(如 'bold', 'normal', '500' 等)。
|
78
|
+
switch_size: {'small', 'medium'}
|
79
|
+
切换开关本身的尺寸。
|
80
|
+
|
81
|
+
Returns
|
82
|
+
-------
|
83
|
+
bool
|
84
|
+
返回切换后的状态。如果无法获取,则返回 default_value。
|
85
|
+
"""
|
86
|
+
|
87
|
+
toggle_value = _component_func(
|
88
|
+
key=key,
|
89
|
+
default_value=default_value,
|
90
|
+
label_start=label_start,
|
91
|
+
label_end=label_end,
|
92
|
+
justify=justify,
|
93
|
+
inactive_color=inactive_color,
|
94
|
+
active_color=active_color,
|
95
|
+
track_color=track_color,
|
96
|
+
label_bg_color_start=label_bg_color_start,
|
97
|
+
label_bg_color_end=label_bg_color_end,
|
98
|
+
background_color_near_button_start=background_color_near_button_start,
|
99
|
+
background_color_near_button_end=background_color_near_button_end,
|
100
|
+
border_radius=border_radius,
|
101
|
+
label_start_color=label_start_color,
|
102
|
+
label_end_color=label_end_color,
|
103
|
+
label_font_size=label_font_size,
|
104
|
+
label_font_weight=label_font_weight,
|
105
|
+
switch_size=switch_size,
|
106
|
+
)
|
107
|
+
return toggle_value if toggle_value is not None else default_value
|
108
|
+
|
109
|
+
|
110
|
+
# 仅在开发环境时演示组件效果
|
111
|
+
if not _RELEASE:
|
112
|
+
st.header('Streamlit Toggle Switch - Dev Mode')
|
113
|
+
st.write('---')
|
114
|
+
|
115
|
+
# 使用 color_picker 选择不同颜色
|
116
|
+
color1_start = st.color_picker('选择 Question 1 标签起始背景颜色', '#FFD700')
|
117
|
+
color1_end = st.color_picker('选择 Question 1 标签结束背景颜色', '#FF8C00')
|
118
|
+
|
119
|
+
color2_start = st.color_picker('选择 Question 2 标签起始背景颜色', '#ADFF2F')
|
120
|
+
color2_end = st.color_picker('选择 Question 2 标签结束背景颜色', '#32CD32')
|
121
|
+
|
122
|
+
color3_start = st.color_picker('选择 Question 3 标签起始背景颜色', '#1E90FF')
|
123
|
+
color3_end = st.color_picker('选择 Question 3 标签结束背景颜色', '#0000FF')
|
124
|
+
|
125
|
+
color4_start = st.color_picker('选择 Question 4 标签起始背景颜色', '#FF69B4')
|
126
|
+
color4_end = st.color_picker('选择 Question 4 标签结束背景颜色', '#FF1493')
|
127
|
+
|
128
|
+
color5_start = st.color_picker('选择 Disable Filter 标签起始背景颜色', '#00FA9A')
|
129
|
+
color5_end = st.color_picker('选择 Disable Filter 标签结束背景颜色', '#00FF7F')
|
130
|
+
|
131
|
+
# 新增颜色选择器用于按钮附近的背景颜色
|
132
|
+
button_bg_start = st.color_picker('按钮附近的起始背景颜色', '#FFFFFF')
|
133
|
+
button_bg_end = st.color_picker('按钮附近的结束背景颜色', '#FFFFFF')
|
134
|
+
|
135
|
+
# 新增圆角选择器
|
136
|
+
border_radius = st.text_input('组件圆角(如:4px, 8px, 50%)', '8px')
|
137
|
+
|
138
|
+
# 新增对齐方式选择器
|
139
|
+
justify = st.selectbox(
|
140
|
+
'标签与开关的对齐方式',
|
141
|
+
('flex-start', 'center', 'flex-end')
|
142
|
+
)
|
143
|
+
|
144
|
+
# 新增标签文字颜色选择
|
145
|
+
label_start_color = st.color_picker("左侧标签文字颜色", "#7f1916")
|
146
|
+
label_end_color = st.color_picker("右侧标签文字颜色", "#FFFFFF")
|
147
|
+
|
148
|
+
# 标签字体大小与粗细
|
149
|
+
label_font_size = st.text_input("标签字体大小", "14px")
|
150
|
+
label_font_weight = st.text_input("标签字体粗细", "bold")
|
151
|
+
|
152
|
+
# Switch 尺寸选择器
|
153
|
+
switch_size = st.selectbox(
|
154
|
+
"Switch 尺寸",
|
155
|
+
("small", "medium")
|
156
|
+
)
|
157
|
+
|
158
|
+
columns = st.columns(3)
|
159
|
+
with columns[0]:
|
160
|
+
st_toggle_switch(
|
161
|
+
key='c1',
|
162
|
+
label_start="Question 1",
|
163
|
+
label_end="", # 不显示后标签
|
164
|
+
justify=justify,
|
165
|
+
default_value=True,
|
166
|
+
inactive_color='#D3D3D3',
|
167
|
+
active_color="#11567f",
|
168
|
+
track_color="#29B5E8",
|
169
|
+
label_bg_color_start=color1_start,
|
170
|
+
label_bg_color_end=color1_end,
|
171
|
+
background_color_near_button_start=button_bg_start,
|
172
|
+
background_color_near_button_end=button_bg_end,
|
173
|
+
border_radius=border_radius,
|
174
|
+
label_start_color=label_start_color,
|
175
|
+
label_end_color=label_end_color,
|
176
|
+
label_font_size=label_font_size,
|
177
|
+
label_font_weight=label_font_weight,
|
178
|
+
switch_size=switch_size,
|
179
|
+
)
|
180
|
+
|
181
|
+
st_toggle_switch(
|
182
|
+
key="input_toggle",
|
183
|
+
label_start="",
|
184
|
+
label_end="Question 2",
|
185
|
+
justify='flex-start',
|
186
|
+
default_value=True,
|
187
|
+
inactive_color='#95e1d3',
|
188
|
+
active_color="#f38181",
|
189
|
+
track_color="#f38181",
|
190
|
+
label_bg_color_start='white',
|
191
|
+
label_bg_color_end='black',
|
192
|
+
background_color_near_button_start='blue',
|
193
|
+
background_color_near_button_end='black',
|
194
|
+
border_radius='10px',
|
195
|
+
label_start_color="#000000",
|
196
|
+
label_end_color="#FFFFFF",
|
197
|
+
label_font_size="12px",
|
198
|
+
label_font_weight="normal",
|
199
|
+
switch_size="small",
|
200
|
+
)
|
201
|
+
|
202
|
+
with columns[1]:
|
203
|
+
st_toggle_switch(
|
204
|
+
key='q2',
|
205
|
+
label_start="", # 不显示前标签
|
206
|
+
label_end="Question 3",
|
207
|
+
justify=justify,
|
208
|
+
default_value=True,
|
209
|
+
inactive_color='#DDA0DD',
|
210
|
+
active_color="#9400D3",
|
211
|
+
track_color="#BA55D3",
|
212
|
+
label_bg_color_start=color3_start,
|
213
|
+
label_bg_color_end=color3_end,
|
214
|
+
background_color_near_button_start=button_bg_start,
|
215
|
+
background_color_near_button_end=button_bg_end,
|
216
|
+
border_radius=border_radius,
|
217
|
+
label_start_color=label_start_color,
|
218
|
+
label_end_color=label_end_color,
|
219
|
+
label_font_size=label_font_size,
|
220
|
+
label_font_weight=label_font_weight,
|
221
|
+
switch_size=switch_size,
|
222
|
+
)
|
223
|
+
st_toggle_switch(
|
224
|
+
key='q3',
|
225
|
+
label_start="", # 不显示前标签
|
226
|
+
label_end="Question 4",
|
227
|
+
justify=justify,
|
228
|
+
default_value=False,
|
229
|
+
inactive_color='#FFA07A',
|
230
|
+
active_color="#FF4500",
|
231
|
+
track_color="#FF6347",
|
232
|
+
label_bg_color_start=color4_start,
|
233
|
+
label_bg_color_end=color4_end,
|
234
|
+
background_color_near_button_start=button_bg_start,
|
235
|
+
background_color_near_button_end=button_bg_end,
|
236
|
+
border_radius=border_radius,
|
237
|
+
label_start_color=label_start_color,
|
238
|
+
label_end_color=label_end_color,
|
239
|
+
label_font_size=label_font_size,
|
240
|
+
label_font_weight=label_font_weight,
|
241
|
+
switch_size=switch_size,
|
242
|
+
)
|
243
|
+
|
244
|
+
with columns[2]:
|
245
|
+
st_toggle_switch(
|
246
|
+
key='q1',
|
247
|
+
label_start="Disable Filter",
|
248
|
+
label_end="", # 不显示后标签
|
249
|
+
justify=justify,
|
250
|
+
default_value=True,
|
251
|
+
inactive_color='#98FB98',
|
252
|
+
active_color="#00FF7F",
|
253
|
+
track_color="#00FA9A",
|
254
|
+
label_bg_color_start=color5_start,
|
255
|
+
label_bg_color_end=color5_end,
|
256
|
+
background_color_near_button_start=button_bg_start,
|
257
|
+
background_color_near_button_end=button_bg_end,
|
258
|
+
border_radius=border_radius,
|
259
|
+
label_start_color=label_start_color,
|
260
|
+
label_end_color=label_end_color,
|
261
|
+
label_font_size=label_font_size,
|
262
|
+
label_font_weight=label_font_weight,
|
263
|
+
switch_size=switch_size,
|
264
|
+
)
|
265
|
+
range_slider_toggle = st_toggle_switch(
|
266
|
+
key='ql',
|
267
|
+
label_start="Disable Filter",
|
268
|
+
label_end="", # 不显示后标签
|
269
|
+
justify=justify,
|
270
|
+
default_value=True,
|
271
|
+
inactive_color='#98FB98',
|
272
|
+
active_color="#00FF7F",
|
273
|
+
track_color="#00FA9A",
|
274
|
+
label_bg_color_start=color5_start,
|
275
|
+
label_bg_color_end=color5_end,
|
276
|
+
background_color_near_button_start=button_bg_start,
|
277
|
+
background_color_near_button_end=button_bg_end,
|
278
|
+
border_radius=border_radius,
|
279
|
+
label_start_color=label_start_color,
|
280
|
+
label_end_color=label_end_color,
|
281
|
+
label_font_size=label_font_size,
|
282
|
+
label_font_weight=label_font_weight,
|
283
|
+
switch_size=switch_size,
|
284
|
+
)
|
285
|
+
range_slider = st.slider(
|
286
|
+
label="Filter Range",
|
287
|
+
min_value=0,
|
288
|
+
max_value=100,
|
289
|
+
disabled=range_slider_toggle,
|
290
|
+
)
|
291
|
+
|
292
|
+
st_toggle_switch(
|
293
|
+
key='q4',
|
294
|
+
label_start="Disable Filter",
|
295
|
+
label_end="Disable Filter",)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"files": {
|
3
|
+
"main.js": "./static/js/main.9f3c3eed.chunk.js",
|
4
|
+
"main.js.map": "./static/js/main.9f3c3eed.chunk.js.map",
|
5
|
+
"runtime-main.js": "./static/js/runtime-main.cc20bba3.js",
|
6
|
+
"runtime-main.js.map": "./static/js/runtime-main.cc20bba3.js.map",
|
7
|
+
"static/js/2.9720bf9e.chunk.js": "./static/js/2.9720bf9e.chunk.js",
|
8
|
+
"static/js/2.9720bf9e.chunk.js.map": "./static/js/2.9720bf9e.chunk.js.map",
|
9
|
+
"index.html": "./index.html",
|
10
|
+
"precache-manifest.b7df6085566f07f8f27b94ee8ed2d302.js": "./precache-manifest.b7df6085566f07f8f27b94ee8ed2d302.js",
|
11
|
+
"service-worker.js": "./service-worker.js",
|
12
|
+
"static/js/2.9720bf9e.chunk.js.LICENSE.txt": "./static/js/2.9720bf9e.chunk.js.LICENSE.txt"
|
13
|
+
},
|
14
|
+
"entrypoints": [
|
15
|
+
"static/js/runtime-main.cc20bba3.js",
|
16
|
+
"static/js/2.9720bf9e.chunk.js",
|
17
|
+
"static/js/main.9f3c3eed.chunk.js"
|
18
|
+
]
|
19
|
+
}
|