Bokeh tools not working in QWebView
Asked Answered
J

0

6

Good afternoon

[First time to post on stackoverflow after years of reading. Exciting!]

I use bokeh to generate html code that I feed into a QWebView in a very simple PyQt4 GUI. The standard tools on top of the bokeh chart do not work in the QWebView, while they work properly if I open the same html code in any standard browser (in my case, Chrome).

Detailed example:

I am using the snippet below taken from an older Bokeh User Guide example to test the issue (the latest User Guide can be found here):

from bokeh.plotting import figure
from bokeh.resources import CDN, INLINE
from bokeh.embed import file_html

# [other code...]

f = figure()
f.circle([1, 2.5, 3, 2], [2, 3, 1, 1.5], radius=0.3, alpha=0.5)        
html = file_html(f, CDN, "my plot")

the 'html' snippet is then fed into a QtWebKit.QWebView instance called 'self.web' embedded in the GUI:

self.web.setHtml(html)

The chart displays properly, however the tools are inactive:

i) the 'Pan' tool is selected and click-and-drag works to pan the chart,

ii) the 'Scroll-wheel' tool is selected but scrolling the wheel does not zoom on the chart,

iii) clicking on any other tool ('Resize', 'Box Zoom', 'Save') does not succeed in selecting the tool

Any idea of what settings are required to make the (static) bokeh html work in the QWebView?

I have searched for related issues, and tried working on the attributes of the QWebView (e.g. setting QtWebKit.QWebSettings.JavascriptEnabled to True) with no effect.

Many thanks for the help.

(the environment is: Python 2.7.8, Anaconda 2.1.0 (64-bit), PyQt4)

Jalisajalisco answered 27/3, 2015 at 15:6 Comment(3)
I would very much like to know the answer to this as wellMaisiemaison
Any update on this? Btw your link to introductory bokeh example is broken. I tried to find it here but I had no luck :(Byword
Thanks, edited the text for clarity with a new link. I ultimately decided to go full web-app and moved to D3 - which is absolutely sweet. The switch from Bokeh to D3 is not obvious and depends on your project. D3 gives more control than Bokeh in my experience, however this is balanced by increasing the lines of code 10-20x (not kidding), and obviously moving to JS for the front-end.Jalisajalisco

© 2022 - 2024 — McMap. All rights reserved.