First let me say I’m pretty new to Bokeh. And let me also say my knowledge of CSS is pretty darn limited (of course this is part of the appeal of Bokeh!)
I am using the DataTable widget in my project. I wanted to provide some CSS styling for this DataTable which I was able to get to work…
What I did (thanks in part to a StackOverlow article or two I found along the way) was to specify the css_classes parameter when I instantiate the DataTable object. Here, I specified a couple of CSS classes…
And then I included the HTML to create those CSS classes within two totally separate Bokeh Div widgets. FWIW here I’m realizing I probably could have included all the code in just one Div widget vs. two…
So my code looks something like this:
foo_table = DataTable(
source = source,
columns = columns,
width = 400,
height = 100,
css_classes = ['table_style', 'table_header_style'])
table_style = Div(text = """
<style>
.table_style{
font-weight: bold !important;
font-size: 10px !important;
}
</style>
""")
table_header_style = Div(text = """
<style>
.slick-header-column{
color: white !important;
background: green !important;
}
</style>
""")
show(
layout(
[other_widget_1, other_widget_2],
foo_table,
table_style,
table_header_style
)
)
So as noted this all works as intended, but I have a few questions:
-
It seems to me that my first CSS class seems to be overwriting the CSS for the SlickGrid table and that the CSS class name really does not matter. However, for the second CSS class, it seems that this class is correctly named to match up with a specific SlickGrid CSS class (I was actually able to find this class I think by clicking through on the page source to the CDN-based JavaScript code)… So is this indeed what is happening?
-
Is there a better way to do what I am doing here? It seems a bit hacky to create a separate Div object that is used for no other purpose than to specify the CSS classes/styles and then to refer to those separately in my DataTable widget. Should the CSS be included in the Web page/Bokeh doc in some other way? I have gone through the Bokeh documentation a good bit and may have missed it, but I’m guessing there may be a better way to include the CSS or to otherwise be able to apply different like styling to the DataTable. FWIW, for now I am just running this code on a desktop, using the show method as noted.
-
I don’t think this is related to my questions above, but I did not notice the below error in the page source. The error does not go away if I totally remove the css_classes parameter from my DataTable and also remove the Div objects. Is this error indicative of something actually missing from my project?
Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing.
Thanks in advance for any help!



