Plotly Dash Share Callback Input in another page with dcc.Store(使用 dcc.Store 在另一个页面中绘制 Dash 共享回调输入)
问题描述
我有一个 2 页的应用程序,在第一页 (app.py) 上,我使用 dcc.Store 在会话缓存中存储一个值,然后尝试在第二页 (app2.py),并将其显示为 html.H1.
i have a 2-page app, on the first page (app.py), i use dcc.Store to store a value in the session cache, and then trying to load this data in the 2nd page (app2.py), and show it as html.H1.
这是我在第一页的代码:
Here is my code in page one:
dcc.Store(id='session', storage_type='session'),
那么我在这个页面的回调是:
then my callback on this page is:
@app.callback(Output('session', 'data'),
[Input('q1', 'value')])
def q1_value(q1):
return {'answer1value': q1}
而q1";是我的 radioitem 中的一个值.
while "q1" is a value from my radioitem.
但是当我运行这个应用程序时,这个 H1 中没有显示任何内容.我花了很多时间来解决这个问题,但失败了,有人可以帮忙吗?
But when i run this app, nothing is shown up in this H1. I have spent many hours fixing this but fail, would anyone please help ?
推荐答案
把你的
dcc.Store(id='session', storage_type='session'),
到app.py,而不是page1.py,在
onto the app.py, not page1.py, under the
app.layout = html.Div([....])
那么你的值就会存储在这里,可以从其他页面调用.
then your value will be stored here, and can be called from other pages.
这篇关于使用 dcc.Store 在另一个页面中绘制 Dash 共享回调输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 dcc.Store 在另一个页面中绘制 Dash 共享回调输入
基础教程推荐
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
