测试代码

测试代码#

from d2py.tools.dashstyle.server import create_app, run_server
from d2py.tools.dashstyle.utils.nav import create_nav

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = create_app(__name__, external_stylesheets=external_stylesheets)

Dash 应用使用和运行:

layout = ... # 布局
await run_server(app, layout, port=8050) # 启动应用

可以直接批量修改文件后缀:

from d2py.tools.sanstyle.utils import rename_suffix
rename_suffix(root, old, new)
root

需要修改的跟目录

old

被修改的文件后缀,如 .txt

new

修改后的文件后缀,如 .rst

创建 <embed> 元素:

from d2py.tools.sanstyle.display.html import Embed

snippet_url = 'https://dash-tests.herokuapp.com'
figure_n_slider_dash = Embed(snippet_url + '/examples/figure-n-slider',
                   className='w3-pale-blue',
                   height=500)
figure_n_slider_dash

导入 plotly-dastsets

import pandas as pd
from d2py.tools.sanstyle.github.file import lfs_url

url = lfs_url('SanstyleLab/plotly-dastsets',
              'simple/usa-agricultural-exports-2011.csv')
df = pd.read_csv(url)
df.head()