散景回调以更新图像 [英] Bokeh callback for image update

查看:67
本文介绍了散景回调以更新图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个散景图,可以显示图像,可以通过滑块更改它(并且应该定期更新)(类似于此问题

I have a Bokeh plot that can display an image, which can be changed by a slider (and also should update regularly) (similar to this question Sliding through images with Bokeh Slider). So the url of the image changes and Bokeh reloads the image. Is there a way to attach a callback function to the load of the image?

推荐答案

从散景1.4.0开始,图像加载没有回调. ImageURL字形并不是由核心开发人员AFAIK广泛使用的,而且我们不能总是预期每个用户可能想要的每个用例.因此,我们使Bokeh本身具有可扩展性,因此,我目前建议的最好办法是使用自定义扩展名扩展Bokeh.用于创建自定义扩展的文档在这里:

As of Bokeh 1.4.0 there is no callback on the image load. The ImageURL glyph is not one that is much used by the core developers, AFAIK, and we can't always anticipate every use case that every user might want. For this reason, we have made Bokeh itself extensible, so the best I can suggest at the moment is to extend Bokeh with a custom extension. The documentation for creating custom extensions is here:

http://docs.bokeh.org/en/latest/docs/user_guide/extensions.html

在缩写形式中,您将创建一个类似这样的类,该类添加一个callback属性,并为您的自定义ImageURL字形提供JavaScript实现:

In abbreviated forms, you'd create a class like this that adds a callback property, and supplies the JavaScript implementation for your custom ImageURL glyph:

class MyImageURL(ImageURL):

     callback = Instance(Callback, help="A callback to run when images load")

    __implementation__ = JAVASCRIPT_CODE_HERE

然后它可以像任何低级glyoh一样使用:

Then it can be used like any low level glyoh:

my_glyph = MyImageURL(...)
source = ColumnDataSource(...)
plot.add_glyph(source, my_glyph)

这篇关于散景回调以更新图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆