如何在散景中获取当前主题的价值?

How to get value of current theme in bokeh?

在散景中,您可以轻松设置主题:

from bokeh.io import curdoc
curdoc().theme = "caliber"

我不确定如何简单地获取 当前主题的字符串读出。我尝试了 curdoc().theme 并返回了 <bokeh.themes.theme.Theme at 0x21637f022c8>。仅使用打印,__repr____str__ 返回相似的结果。简单地检查 dir(curdoc().theme) 的输出并没有揭示任何我可能会尝试的明显的吸气剂(但我可能遗漏了一些明显的东西)。

Theme 不包含该信息,但您可以尝试:

from bokeh.themes import built_in_themes

theme = curdoc().theme
theme_name = next(k for k, v in built_in_themes.items() if v is theme)