散景通知段落小部件 - 无法插入换行符
Bokeh notification Paragraph widget -- can't insert newline
在 bokeh/python 中,我试图让段落小部件像输出控制台一样工作。所以我会定期更新它的文本。但是我似乎无法在该框中插入换行符。这意味着控制台几乎不可读。这是一个最小的例子:
from bokeh.io import curdoc
from bokeh.models.widgets import Paragraph, Button
from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
notifications = Paragraph(text='initial text')#, name=name, width=width, height=height)
button = Button(label="Click me to add text")
def callback():
notifications.text += 'more text' + '\n'
button.on_click(callback)
# Set up layout and add to document
box = widgetbox(notifications, button)
curdoc().add_root(row(box))
行中的'\n'
notifications.text += 'more text' + '\n'
什么都不做,无论它是否存在。我也试过
notifications.text += 'more text' + '<br />'
万一这里解释html,就不行了。我还能尝试什么?
我建议使用支持 HTML 的 Div 小部件,请参阅
您的示例将变为:
from bokeh.io import curdoc
from bokeh.models.widgets import Div, Button
from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
notifications = Div(text='initial text')#, name=name, width=width, height=height)
button = Button(label="Click me to add text")
def callback():
notifications.text += 'more text' + '</br>'
button.on_click(callback)
# Set up layout and add to document
box = widgetbox(notifications, button)
curdoc().add_root(row(box))
在 bokeh/python 中,我试图让段落小部件像输出控制台一样工作。所以我会定期更新它的文本。但是我似乎无法在该框中插入换行符。这意味着控制台几乎不可读。这是一个最小的例子:
from bokeh.io import curdoc
from bokeh.models.widgets import Paragraph, Button
from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
notifications = Paragraph(text='initial text')#, name=name, width=width, height=height)
button = Button(label="Click me to add text")
def callback():
notifications.text += 'more text' + '\n'
button.on_click(callback)
# Set up layout and add to document
box = widgetbox(notifications, button)
curdoc().add_root(row(box))
行中的'\n'
notifications.text += 'more text' + '\n'
什么都不做,无论它是否存在。我也试过
notifications.text += 'more text' + '<br />'
万一这里解释html,就不行了。我还能尝试什么?
我建议使用支持 HTML 的 Div 小部件,请参阅
您的示例将变为:
from bokeh.io import curdoc
from bokeh.models.widgets import Div, Button
from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
notifications = Div(text='initial text')#, name=name, width=width, height=height)
button = Button(label="Click me to add text")
def callback():
notifications.text += 'more text' + '</br>'
button.on_click(callback)
# Set up layout and add to document
box = widgetbox(notifications, button)
curdoc().add_root(row(box))