[FEATURE] Add a `PythonCallback` similar to `CustomJS`
See original GitHub issueAdd a new model to allow a python-side callback that’s called from the browser. If this is possible, I didn’t find any way to do that in the docs.
Note that this can also simplify the event-mechanism as there will not be longer be a need for both on_event
and js_on_event
.
Looking briefly on the code, I have an implementation suggestion (tell me what you think about it):
In the python side, it just wraps a callback.
On the browser side, this could be implemented by triggering a new type of event on calling CallbackLike<..>.execute
, which, in turn, triggers a wrapper in the python-side that calls the given callback.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
JavaScript callbacks — Bokeh 2.4.3 Documentation
Any Bokeh models that are configured in args (on the “Python side”) will ... These CustomJS callbacks can be attached to property change...
Read more >Bokeh: CustomJS and Callbacks - YouTube
In order for a widget to be useful, it needs to be able to perform some action. Using the Bokeh server, it is...
Read more >Bokeh widgets call CustomJS and Python callback for single ...
With certain events, I'd like to execute some JavaScript code before making the callback to the Python function. Is this possible? In this...
Read more >Lesson 30: JavaScript for stand-alone Bokeh apps
The callbacks, which are functions that get executed to update information about the plot based on changes in the widgets (such as computing...
Read more >Panel - JSCallback function - HoloViz Discourse
There is no easy way to call a jscallback from python, I think, but I am not sure. stackoverflow.com · austintpg. Bokeh callbacks...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s more complicated, not less. You can just currently define a function and pass to
on_event
with no imports. To use somePythonCallback
you have to: import it (know to import it), define a function and configure it, or subclass is and define a method, then configure that result on the model. That is strictly always more work, not less (and more and more ways to have to document)This could only work with a Bokeh server because the Bokeh server is the Python process that will execute python code. (I hope that is understood here but I am not sure). It cannot work at all with standalone output (i.e.
output_file
+show
) but it seems like it would be very easy for users to be confused on this point, which directly translates into an inctreased support burden.There are only three left.
CustomAction
,TapTool
, andHoverTool
It used to be the case there there were lots but the plan (which has been ongoing) is to get rid of all of the old ad-hoccallback
properties and have only the one consistenton_event
/js_on_event
mechanism everywhere. These will all be deprecated some day.This is duplicative of existing functionality but will require more work to develop, maintain, document, and explain. We should continue the work to unify everything event-related under common
on_event
/js_on_event
which is easier to explain via parallel comparison. If we need new events, we can add them. But I am a strong -1 on a differentPythonCallback
that needs to be maintained (and explained) differently. .FYI I will go ahead and close this with
noaction
if others feel strongly please make a case to re-open