本文整理汇总了Python中dash.callback_context方法的典型用法代码示例。如果您正苦于以下问题:Python dash.callback_context方法的具体用法?Python dash.callback_context怎么用?Python dash.callback_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dash
的用法示例。
在下文中一共展示了dash.callback_context方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_image
# 需要导入模块: import dash [as 别名]
# 或者: from dash import callback_context [as 别名]
def get_image(tab, get_jpg_clicks, get_png_clicks, get_svg_clicks):
# File type to ouput of 'svg, 'png', 'jpg', or 'jpeg' (alias of 'jpg')
ftype = tab
# 'store': Stores the image data in 'imageData' !only jpg/png are supported
# 'download'`: Downloads the image as a file with all data handling
# 'both'`: Stores image data and downloads image as file.
action = 'store'
ctx = dash.callback_context
if ctx.triggered:
input_id = ctx.triggered[0]["prop_id"].split(".")[0]
if input_id != "tabs":
action = "download"
ftype = input_id.split("-")[-1]
# random print statement needed to pass pylint
print(get_jpg_clicks, get_png_clicks, get_svg_clicks)
return {
'type': ftype,
'action': action
}
示例2: display
# 需要导入模块: import dash [as 别名]
# 或者: from dash import callback_context [as 别名]
def display(btn1, btn2, btn3):
ctx = dash.callback_context
if not ctx.triggered:
button_id = 'No clicks yet'
else:
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
ctx_msg = json.dumps({
'states': ctx.states,
'triggered': ctx.triggered,
'inputs': ctx.inputs
}, indent=2)
return html.Div([
html.Table([
html.Tr([html.Th('Button 1'),
html.Th('Button 2'),
html.Th('Button 3'),
html.Th('Most Recent Click')]),
html.Tr([html.Td(btn1 or 0),
html.Td(btn2 or 0),
html.Td(btn3 or 0),
html.Td(button_id)])
]),
html.Pre(ctx_msg)
])