问题描述
如果我通过bokeh serve --show
提供服务,如何通过css_classes
将CSS属性分配给通过css_classes
分配给小部件的自定义类?
from bokeh.models import Button
button = Button(label="Press Me", css_classes=['myclass'])
curdoc().add_root(button)
如果您不介意使用html模板,则一旦定义了css类,便可以在css文件中设置其样式. (如果您想在python中包含CSS样式,则此答案将无济于事)
可以内联或通过包含外部css文件将其包含在html文档中.散景图库中有一些示例(请参见下面的链接).
文档中描述的bokeh应用程序文件夹结构:
https://docs.bokeh.org/en/latest/docs/user_guide/server.html#directory-format
在此处查看示例:
https://github.com/bokeh/bokeh/tree/master/examples/app/gapminder
这是另一个使用外部CSS的应用程序:
https://gist.github.com/anthonydouc/c8571f0a2f9aa8415bd566e1ac2ba237
How to assign css proprties to a custom class assigned to a widget through css_classes
if I'm serving my app through bokeh serve --show
?
from bokeh.models import Button
button = Button(label="Press Me", css_classes=['myclass'])
curdoc().add_root(button)
If you dont mind using a html template, once you define your css classes, their styles can be set in a css file. (If you want to include the css styles from within python this answer wont help you)
This can be included in the html document either inline or by including an external css file. There are some examples in the bokeh gallery (see below links).
The bokeh application folder structure described in the docs:
https://docs.bokeh.org/en/latest/docs/user_guide/server.html#directory-format
See an example here:
https://github.com/bokeh/bokeh/tree/master/examples/app/gapminder
Here is another application which uses external css:
https://gist.github.com/anthonydouc/c8571f0a2f9aa8415bd566e1ac2ba237
这篇关于如何使用bokeh服务设置自定义CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!