如何获得博克当前主题的价值?

2024-06-01 09:10:14 发布

您现在位置:Python中文网/ 问答频道 /正文

在bokeh,您可以轻松设置主题:

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

我不知道如何简单地获得当前主题的字符串读数。我尝试了curdoc().theme,结果返回了<bokeh.themes.theme.Theme at 0x21637f022c8>。仅使用打印,__repr____str__返回类似的结果。仅仅检查dir(curdoc().theme)的输出并没有发现任何明显的getter,我可能会尝试(但我可能遗漏了一些明显的东西)


Tags: 字符串fromioimport主题bokehthemethemes
1条回答
网友
1楼 · 发布于 2024-06-01 09:10:14

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)

相关问题 更多 >