本文整理匯總了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)
])