open local file using taptool

Hi,

I wonder if it is possible to open a local file using taptool

I am trying something like this:

taptool.action=OpenURL(url="/Users/joegi/Desktop/inter.html")

but it doesn’t work.

It seems that it is trying to open: http://localhost:8888/Users/joegi/Desktop/inter.html

joegi

Hi Joe,

The tool just calls the JavaScript function `window.open()`. Presumabely if you don't specify a protocol it defaults to "http" and whatever host the current document is on. So it might work if you give it "file" specifically:

  file://Users/joegi/Desktop/inter.htm

I've not had a chance to test this. If it works for you, a PR that adds a note to the docstring or User's Guide (or both) explaining this would be very appreciated.

Thanks,

Bryan

···

On Jun 11, 2015, at 4:29 PM, 'joe gi' via Bokeh Discussion - Public <[email protected]> wrote:

Hi,

I wonder if it is possible to open a local file using taptool

I am trying something like this:

taptool.action=OpenURL(url="/Users/joegi/Desktop/inter.html")

but it doesn't work.

It seems that it is trying to open: http://localhost:8888/Users/joegi/Desktop/inter.html

joegi

--
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/0565890c-f29b-49b7-8fb9-15be55fcf1de%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi,

I tried something like this:

taptool.action=OpenURL(url=“file:///Users/joegi/Desktop/inter.html”)

but it does not do anything.

jg

···

From: Bryan Van de Ven [email protected]
To: [email protected]
Sent: Friday, June 12, 2015 1:18 AM
Subject: Re: [bokeh] open local file using taptool

Hi Joe,

The tool just calls the JavaScript function window.open(). Presumabely if you don’t specify a protocol it defaults to “http” and whatever host the current document is on. So it might work if you give it “file” specifically:

file://Users/joegi/Desktop/inter.htm

I’ve not had a chance to test this. If it works for you, a PR that adds a note to the docstring or User’s Guide (or both) explaining this would be very appreciated.

Thanks,

Bryan

On Jun 11, 2015, at 4:29 PM, ‘joe gi’ via Bokeh Discussion - Public [email protected] wrote:

Hi,

I wonder if it is possible to open a local file using taptool

I am trying something like this:

taptool.action=OpenURL(url=“/Users/joegi/Desktop/inter.html”)

but it doesn’t work.

It seems that it is trying to open: http://localhost:8888/Users/joegi/Desktop/inter.html

joegi


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/0565890c-f29b-49b7-8fb9-15be55fcf1de%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/25B844BB-0538-4994-9A58-0B3ED277E669%40continuum.io.

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

Hi,

Ok, it does not work in the notebook but it works ok if you save the file to html

I tried something like this:

url = “file:///Users/joegi/Desktop/opt/camilo_dakota/c1/links/f1.png”
taptool = p1.select(type=TapTool)
taptool.action=OpenURL(url=url)

Joel

···

From: Bryan Van de Ven [email protected]
To: [email protected]
Sent: Friday, June 12, 2015 1:18 AM
Subject: Re: [bokeh] open local file using taptool

Hi Joe,

The tool just calls the JavaScript function window.open(). Presumabely if you don’t specify a protocol it defaults to “http” and whatever host the current document is on. So it might work if you give it “file” specifically:

file://Users/joegi/Desktop/inter.htm

I’ve not had a chance to test this. If it works for you, a PR that adds a note to the docstring or User’s Guide (or both) explaining this would be very appreciated.

Thanks,

Bryan

On Jun 11, 2015, at 4:29 PM, ‘joe gi’ via Bokeh Discussion - Public [email protected] wrote:

Hi,

I wonder if it is possible to open a local file using taptool

I am trying something like this:

taptool.action=OpenURL(url=“/Users/joegi/Desktop/inter.html”)

but it doesn’t work.

It seems that it is trying to open: http://localhost:8888/Users/joegi/Desktop/inter.html

joegi


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/0565890c-f29b-49b7-8fb9-15be55fcf1de%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/25B844BB-0538-4994-9A58-0B3ED277E669%40continuum.io.

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

Hi,

sorry to dig up this older message, but did somebody found a workaround? Executing this script works via compiling to .html with show() but not when using the bokeh server. I need this to work via bokeh server…

from bokeh.io import curdoc

from bokeh.models import ColumnDataSource,TapTool,CustomJS

from bokeh.plotting import figure

source = ColumnDataSource(data=dict(x=[1, 2, 3],y=[2, 5, 8]))

plot=figure(tools=‘tap’,plot_width=300,plot_height=300)

plot.circle(x=‘x’,y=‘y’,source=source,size=20)

taptool = plot.select(type=TapTool)

#code=“”“window.open(‘E:\test.html’);”“”#doesn’t work via bokeh serve, otherwise it does. The http like below always works.

taptool.callback = CustomJS(args=dict(source=source), code=“”“window.open(‘http://google.com’);”“”)

doc1=curdoc()

doc1.add_root(plot)

Kind regards,
Joris

···

On Sunday, June 14, 2015 at 1:55:42 AM UTC+2, joe gi wrote:

Hi,

Ok, it does not work in the notebook but it works ok if you save the file to html

I tried something like this:

url = “file:///Users/joegi/Desktop/opt/camilo_dakota/c1/links/f1.png”
taptool = p1.select(type=TapTool)
taptool.action=OpenURL(url=url)

Joel


From: Bryan Van de Ven [email protected]
To: [email protected]
Sent: Friday, June 12, 2015 1:18 AM
Subject: Re: [bokeh] open local file using taptool

Hi Joe,

The tool just calls the JavaScript function window.open(). Presumabely if you don’t specify a protocol it defaults to “http” and whatever host the current document is on. So it might work if you give it “file” specifically:

file://Users/joegi/Desktop/inter.htm

I’ve not had a chance to test this. If it works for you, a PR that adds a note to the docstring or User’s Guide (or both) explaining this would be very appreciated.

Thanks,

Bryan

On Jun 11, 2015, at 4:29 PM, ‘joe gi’ via Bokeh Discussion - Public [email protected] wrote:

Hi,

I wonder if it is possible to open a local file using taptool

I am trying something like this:

taptool.action=OpenURL(url=“/Users/joegi/Desktop/inter.html”)

but it doesn’t work.

It seems that it is trying to open: http://localhost:8888/Users/joegi/Desktop/inter.html

joegi

Hi,

It’s not possible to use your file system’s paths.

You can read more details here: "Not allowed to load local resource: file:///C:....jpg" Java EE Tomcat - Stack Overflow

What you can do, however, is to create a more sophisticated script that uses e.g. tornado.web.StaticFileHandler that would serve some local directory.

But I think you’ll have to follow Bokeh server — Bokeh 3.3.2 Documentation to create your server.

Regards,

Eugene

···

On Thursday, September 21, 2017 at 10:23:47 PM UTC+7, JMeert wrote:

Hi,

sorry to dig up this older message, but did somebody found a workaround? Executing this script works via compiling to .html with show() but not when using the bokeh server. I need this to work via bokeh server…

from bokeh.io import curdoc

from bokeh.models import ColumnDataSource,TapTool,CustomJS

from bokeh.plotting import figure

source = ColumnDataSource(data=dict(x=[1, 2, 3],y=[2, 5, 8]))

plot=figure(tools=‘tap’,plot_width=300,plot_height=300)

plot.circle(x=‘x’,y=‘y’,source=source,size=20)

taptool = plot.select(type=TapTool)

#code=“”“window.open(‘E:\test.html’);”“”#doesn’t work via bokeh serve, otherwise it does. The http like below always works.

taptool.callback = CustomJS(args=dict(source=source), code=“”“window.open(‘http://google.com’);”“”)

doc1=curdoc()

doc1.add_root(plot)

Kind regards,
Joris

On Sunday, June 14, 2015 at 1:55:42 AM UTC+2, joe gi wrote:

Hi,

Ok, it does not work in the notebook but it works ok if you save the file to html

I tried something like this:

url = “file:///Users/joegi/Desktop/opt/camilo_dakota/c1/links/f1.png”
taptool = p1.select(type=TapTool)
taptool.action=OpenURL(url=url)

Joel


From: Bryan Van de Ven [email protected]
To: [email protected]
Sent: Friday, June 12, 2015 1:18 AM
Subject: Re: [bokeh] open local file using taptool

Hi Joe,

The tool just calls the JavaScript function window.open(). Presumabely if you don’t specify a protocol it defaults to “http” and whatever host the current document is on. So it might work if you give it “file” specifically:

file://Users/joegi/Desktop/inter.htm

I’ve not had a chance to test this. If it works for you, a PR that adds a note to the docstring or User’s Guide (or both) explaining this would be very appreciated.

Thanks,

Bryan

On Jun 11, 2015, at 4:29 PM, ‘joe gi’ via Bokeh Discussion - Public [email protected] wrote:

Hi,

I wonder if it is possible to open a local file using taptool

I am trying something like this:

taptool.action=OpenURL(url=“/Users/joegi/Desktop/inter.html”)

but it doesn’t work.

It seems that it is trying to open: http://localhost:8888/Users/joegi/Desktop/inter.html

joegi