散景布局与按钮的垂直对齐 [英] bokeh layout vertical alignment with buttons
本文介绍了散景布局与按钮的垂直对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找Bokeh中问题的解决方法. 当您连续放置一个按钮和一个文本输入时,它们将不会被忽略.发生这种效果是因为文本输入带有标签,并在此处进行了描述: https://github.com/bokeh/bokeh/issues/4817
I am looking for a workaround to an issue in Bokeh. When you put a button and a text input in a row- they will be un-alighned. This effect happens because the text input has a label and is described here: https://github.com/bokeh/bokeh/issues/4817
示例代码:
# hello.py
from bokeh.io import curdoc
from bokeh.layouts import column, row
from bokeh.models.widgets import TextInput, Button, Paragraph
# create some widgets
button = Button(label="Say HI")
input = TextInput(value="Bokeh")
output = Paragraph()
# add a callback to a widget
def update():
output.text = "Hello, " + input.value
button.on_click(update)
# create a layout for everything
#layout = VBox(children=[HBox(children=[button, input]), output])
layout = column(row(button, input), output)
# add the layout to curdoc
curdoc().add_root(layout)
推荐答案
设置TextInput
的css_classes
属性:
input = TextInput(value="Bokeh", css_classes=["hide-label"])
如果您的应用程序是文件夹,请在文件夹的index.html
中添加样式:
Add style to index.html
in templates folder if your application is a folder:
<style>
.hide-label label{
display: none !important;
}
</style>
如果应用程序是脚本文件,则在样式表中添加Div
元素.
If the application is a script file, then add a Div
element with the style sheet.
这篇关于散景布局与按钮的垂直对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文