[英]How can I show and update a list of print statements in a Bokeh dashboard?
Is there a way to create a section of a bokeh dashboard that shows the console output from the python session? 有没有办法创建一个散景仪表板的一部分,显示python会话的控制台输出?
I am creating a front-end dashboard with bokeh that runs a process that can take a while and does a lot of stuff. 我正在创建一个带有散景的前端仪表板,它可以运行一段时间并且可以完成很多工作。 I wanted a section that would show some of the print statements that are executed along the way.
我想要一个部分,它将显示一些在此过程中执行的打印语句。 Ideally I was hoping for a little widget type object that could display the output directly within the dashboard.
理想情况下,我希望有一个小窗口小部件类型的对象可以直接在仪表板中显示输出。
Just a simple example updating a Div
element with the content of a list os messages (with html code). 只是一个简单的例子,用列表消息(带有html代码)的内容更新
Div
元素。 I think you can adapt this to your needs: 我想你可以根据自己的需要调整它:
from bokeh.layouts import column
from bokeh.io import curdoc
from bokeh.models import Button
from bokeh.models.widgets import Div
div = Div(
text='',
width=200,
height=200
)
msg_list = []
def update_div():
msg_num = len(msg_list)
msg_list.append('{}: New message'.format(msg_num))
m = ''
for msg in msg_list:
m += '<li>{}</li>'.format(msg)
div.text = '<ul>{}</ul>'.format(m)
bt = Button(
label="Update div",
button_type="success",
width=50
)
bt.on_click(update_div)
curdoc().add_root(
column(children=[bt, div])
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.