Bokeh tools not working in QWebView

不打扰是莪最后的温柔 提交于 2019-12-01 03:21:49

问题


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)

来源:https://stackoverflow.com/questions/29303912/bokeh-tools-not-working-in-qwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!