Manually trigger Python callback from Javascript

I’m trying to link up an HTML5

Hi - I am not sure I understand your post completely - Are you trying to do something like ohlc in the bokeh examples, where a bokeh plot is updated by some datafeed?

···

On Sunday, August 21, 2016 at 7:17:54 PM UTC-5, Henry Harrison wrote:

I’m trying to link up an HTML5

No, I have something like that working fine already. What I want now is to update a plot based on the current seek time of a video on the same page as the Bokeh plot. In a sense, for the seek bar of the video control to behave like a Bokeh slider. Ideally, I could set the timeupdate callback on the video element to trigger a Python function server-side. It might look like this:

video.ontimeupdate = function () {

Bokeh.client.current_session.call_python_function('update_plot', video.currenttime);

};

where I am imagining how BokehJS might expose the functionality of triggering a function on the Python side. But my JS-fu is not strong enough to figure out how this is actually exposed.

An alternative I just thought of is to make a dummy slider, find it with Bokeh.index, and

video.ontimeupdate = function() {

slider.value = video.currenttime;

};

therefore triggering the Python callback for the dummy slider. But now I have the problem of hiding the slider. I can probably figure out a way to do that… but, the original question then boils down to, is there a way to cut out the middleman and trigger a Python callback directly from BokehJS?

···

On Sun, Aug 21, 2016 at 10:00 PM, Itay Livni [email protected] wrote:

Hi - I am not sure I understand your post completely - Are you trying to do something like ohlc in the bokeh examples, where a bokeh plot is updated by some datafeed?

On Sunday, August 21, 2016 at 7:17:54 PM UTC-5, Henry Harrison wrote:

I’m trying to link up an HTML5

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/V4PSzLG9-X0/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6efe478d-9a32-4e3e-b172-7daf072abb10%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

To communicate from JS to python, you need to change some property value on some Bokeh model (in JS) and have defined a callback on that property (in python). There is an open feature request to add a "namespace" object that could be used as a scratch space to store arbitrary user-defined properties for this kind of data exchange. But no-one has had the opportunity to work on it yet. So, for now you will have to "fake it". By way of suggestion, you could create an invisible glyph, and pass values through its renderer data source.

Thanks,

Bryan

···

On Aug 21, 2016, at 7:17 PM, Henry Harrison <[email protected]> wrote:

I'm trying to link up an HTML5 <video> with a Bokeh server. I want a plot to update continuously based on the time of the video. I can communicate in the Python --> JS direction, updating the video's seek position based on a Bokeh slider for example, but I can't seem to go in the other direction. I'd like to set the timeupdate callback on the video object to trigger a Python function. Is this possible?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9abb9147-b36b-43e4-bf22-97ecc58398b9%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Thanks Bryan. Dummy glyph is easier than dummy slider. I will subscribe to the GH issue to stay up to date.

···

On Sun, Aug 21, 2016 at 10:16 PM, Bryan Van de Ven [email protected] wrote:

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

To communicate from JS to python, you need to change some property value on some Bokeh model (in JS) and have defined a callback on that property (in python). There is an open feature request to add a “namespace” object that could be used as a scratch space to store arbitrary user-defined properties for this kind of data exchange. But no-one has had the opportunity to work on it yet. So, for now you will have to “fake it”. By way of suggestion, you could create an invisible glyph, and pass values through its renderer data source.

Thanks,

Bryan

On Aug 21, 2016, at 7:17 PM, Henry Harrison [email protected] wrote:

I’m trying to link up an HTML5

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9abb9147-b36b-43e4-bf22-97ecc58398b9%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/V4PSzLG9-X0/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C1EF197-255F-4405-A069-20B6A06001AD%40continuum.io.

Actually, the dummy glyph handles the issue of passing data, but not actually triggering a callback. So I would still need to either use a dummy widget to actually trigger an update, or use a periodic callback. Or am I misunderstanding?

···

On Sun, Aug 21, 2016 at 10:17 PM, Henry Harrison [email protected] wrote:

Thanks Bryan. Dummy glyph is easier than dummy slider. I will subscribe to the GH issue to stay up to date.

On Sun, Aug 21, 2016 at 10:16 PM, Bryan Van de Ven [email protected] wrote:

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

To communicate from JS to python, you need to change some property value on some Bokeh model (in JS) and have defined a callback on that property (in python). There is an open feature request to add a “namespace” object that could be used as a scratch space to store arbitrary user-defined properties for this kind of data exchange. But no-one has had the opportunity to work on it yet. So, for now you will have to “fake it”. By way of suggestion, you could create an invisible glyph, and pass values through its renderer data source.

Thanks,

Bryan

On Aug 21, 2016, at 7:17 PM, Henry Harrison [email protected] wrote:

I’m trying to link up an HTML5

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9abb9147-b36b-43e4-bf22-97ecc58398b9%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/V4PSzLG9-X0/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C1EF197-255F-4405-A069-20B6A06001AD%40continuum.io.

For reference, it is Add DataModel base class · Issue #3674 · bokeh/bokeh · GitHub

Thanks,

Bryan

···

On Aug 21, 2016, at 9:17 PM, Henry Harrison <[email protected]> wrote:

Thanks Bryan. Dummy glyph is easier than dummy slider. I will subscribe to the GH issue to stay up to date.

On Sun, Aug 21, 2016 at 10:16 PM, Bryan Van de Ven <[email protected]> wrote:
Hi,

To communicate from JS to python, you need to change some property value on some Bokeh model (in JS) and have defined a callback on that property (in python). There is an open feature request to add a "namespace" object that could be used as a scratch space to store arbitrary user-defined properties for this kind of data exchange. But no-one has had the opportunity to work on it yet. So, for now you will have to "fake it". By way of suggestion, you could create an invisible glyph, and pass values through its renderer data source.

Thanks,

Bryan

> On Aug 21, 2016, at 7:17 PM, Henry Harrison <[email protected]> wrote:
>
> I'm trying to link up an HTML5 <video> with a Bokeh server. I want a plot to update continuously based on the time of the video. I can communicate in the Python --> JS direction, updating the video's seek position based on a Bokeh slider for example, but I can't seem to go in the other direction. I'd like to set the timeupdate callback on the video object to trigger a Python function. Is this possible?
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9abb9147-b36b-43e4-bf22-97ecc58398b9%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/V4PSzLG9-X0/unsubscribe\.
To unsubscribe from this group and all its topics, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C1EF197-255F-4405-A069-20B6A06001AD%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOTx%2BPt5w4JRxyRjF1oMT8z%3D3mTH297dbZ4u1BgJmNnLAA1aNQ%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.