Simplified Chinese | English
Contains a series of tool functions/tool classes for improving the efficiency of Dash application development.
Install and participate in the contribution development plan with the vscode plug-in.
pip install feffery-dash-utils -U In vscode , with the plug-in feffery-dash-snippets, you can quickly implement the quick import of various tool functions/tool classes. Enter utils: in the Python file to trigger the relevant shortcut commands.
style() style parameter dictionary used to quickly generate Dash components has built-in common css attributes in most small camel naming formats. Hover the mouse over the parameter name in common ideas to view the corresponding Chinese and English attribute function introduction. The content is automatically generated based on w3cschool .
Example of usage
from feffery_dash_utils . style_utils import style
# 方式一:直接编写键值对样式
fac . AntdText (
'测试' ,
style = style (
fontSize = 16 ,
color = 'red'
)
)
# 方式二:解析CSS代码片段
fac . AntdText (
'测试' ,
style = style (
"""
.IvkwhTOsc9wu6RdvHESR .yK52Sq0w7wspWaS28YNl {
width: 91.46%;
margin-left: 4.27%;
margin-bottom: 5%;
position: relative;
}"""
)
)
# 方式三:混合使用
fac . AntdText (
'测试' ,
style = style (
"""
.IvkwhTOsc9wu6RdvHESR .yK52Sq0w7wspWaS28YNl {
width: 91.46%;
margin-left: 4.27%;
margin-bottom: 5%;
position: relative;
}""" ,
fontSize = 16 ,
color = 'red'
)
)TreeManager It is used to perform quick management operations on tree structure data that tree components such as AntdTree and AntdTreeSelect depend on. The specific methods include:
update_tree_node() Used to perform overall or incremental updates to the corresponding nodes of the specified key in the tree structure data.
Example of usage
from feffery_dash_utils . tree_utils import TreeManager
# 示例树形数据
demo_tree = [
{
'title' : '节点1' ,
'key' : '节点1' ,
'children' : [
{
'title' : '节点1-1' ,
'key' : '节点1-1' ,
'children' : [
{
'title' : '节点1-1-1' ,
'key' : '节点1-1-1' ,
},
{
'title' : '节点1-1-2' ,
'key' : '节点1-1-2' ,
},
],
}
],
},
{ 'title' : '节点2' , 'key' : '节点2' },
]
# 对示例树形数据指定节点进行整体替换
TreeManager . update_tree_node (
demo_tree ,
'节点1-1' ,
{ 'title' : '节点1-1' , 'key' : '节点1-1' },
)
# 对示例树形数据指定节点进行增量更新
TreeManager . update_tree_node (
demo_tree ,
'节点1-1' ,
{ 'title' : '节点1-1new' },
'overlay' ,
)add_node_before() Insert a new horizontal node before specifying key corresponding node in the tree structure data.
Example of usage
from feffery_dash_utils . tree_utils import TreeManager
# 示例树形数据
demo_tree = [
{
'title' : '节点1' ,
'key' : '节点1' ,
'children' : [
{
'title' : '节点1-1' ,
'key' : '节点1-1' ,
'children' : [
{
'title' : '节点1-1-1' ,
'key' : '节点1-1-1' ,
},
{
'title' : '节点1-1-2' ,
'key' : '节点1-1-2' ,
},
],
}
],
},
{ 'title' : '节点2' , 'key' : '节点2' },
]
# 在示例树形数据指定节点前插入平级新节点
TreeManager . add_node_before (
demo_tree ,
'节点1-1' ,
{ 'title' : '节点1-0' , 'key' : '节点1-0' },
)add_node_after() Insert a new horizontal node after specifying the corresponding node of key in the tree structure data.
Example of usage
from feffery_dash_utils . tree_utils import TreeManager
# 示例树形数据
demo_tree = [
{
'title' : '节点1' ,
'key' : '节点1' ,
'children' : [
{
'title' : '节点1-1' ,
'key' : '节点1-1' ,
'children' : [
{
'title' : '节点1-1-1' ,
'key' : '节点1-1-1' ,
},
{
'title' : '节点1-1-2' ,
'key' : '节点1-1-2' ,
},
],
}
],
},
{ 'title' : '节点2' , 'key' : '节点2' },
]
# 在示例树形数据指定节点后插入平级新节点
TreeManager . add_node_after (
demo_tree ,
'节点1-1' ,
{ 'title' : '节点1-2' , 'key' : '节点1-2' },
)delete_node() Delete the node corresponding to the specified key in the tree structure data.
Example of usage
from feffery_dash_utils . tree_utils import TreeManager
# 示例树形数据
demo_tree = [
{
'title' : '节点1' ,
'key' : '节点1' ,
'children' : [
{
'title' : '节点1-1' ,
'key' : '节点1-1' ,
'children' : [
{
'title' : '节点1-1-1' ,
'key' : '节点1-1-1' ,
},
{
'title' : '节点1-1-2' ,
'key' : '节点1-1-2' ,
},
],
}
],
},
{ 'title' : '节点2' , 'key' : '节点2' },
]
# 删除示例树形数据指定节点
TreeManager . delete_node ( demo_tree , '节点2' )get_node() Query the node corresponding to the specified key in the tree structure data.
Example of usage
from feffery_dash_utils . tree_utils import TreeManager
# 示例树形数据
demo_tree = [
{
'title' : '节点1' ,
'key' : '节点1' ,
'children' : [
{
'title' : '节点1-1' ,
'key' : '节点1-1' ,
'children' : [
{
'title' : '节点1-1-1' ,
'key' : '节点1-1-1' ,
},
{
'title' : '节点1-1-2' ,
'key' : '节点1-1-2' ,
},
],
}
],
},
{ 'title' : '节点2' , 'key' : '节点2' },
]
# 查询示例树形数据中存在的指定节点
TreeManager . get_node ( demo_tree , '节点1-1' )
# 查询示例树形数据中不存在的指定节点(将返回None)
TreeManager . get_node ( demo_tree , '节点1-666' )Translator It is used to quickly build international multilingual solutions in Dash applications, based on front-end cookies and local international configuration file drivers.
Example of usage
See i18n_test_app.py, i18n_multi_test_app.py for example applications. See locales.json, locales1.json, locales2.json for reference configuration files.
git clone https://github.com/CNFeffery/feffery-dash-utils.git
cd feffery-dash-utils
# 安装开发环境所需依赖
pip install -r requirements/dev.txtstyle_utils style style() layout_utils router_utils template_utils table_utils callback_utils tree_utils TreeManager update_tree_node() add_node_before() add_node_after() after the tree node is inserted delete_node() get_node() theme_utils i18n_utils Translator