My supervisor has asked if I can add a “print” and an “email” tool to the images I produce in Bokeh. Has anybody ever done this?
CustomAction Bokeh object to add a new toolbar button, or you could use a separate
Button outside the plot.
AFAIK the only readily available JS API available is
window.printwhich will print the entire window (after a confirmation dialog)
Alternatively, you could save a PNG of a single Bokeh plot the same way the built-in
SaveTooldoes, and send the image to some other server or REST API you have set up that can accept the image and print it.
I think the only option here is the second one above: generate a PNG of a plot canvas then send that data to some other running server or service you have set up that can actually generate and send off the email. Maybe you can send a message directly to some email server directly from JS but I am skeptical.
If this is a Bokeh server app things are perhaps a bit simpler. You can use
export_png directly in Python code to generate PNGs (instead of doing it via JS code), and then the Python code can print or email however you would normally print or email from Python code in your environment.