即使使用 WinPython 环境,我也有以下代码可以在 linux 和我的 windows 7 机器上运行:
I have following code that works on linux and my windows 7 machine even using WinPython environment:
# plt_file is valid html produced by Bokeh and that is correctly displayed in browser
with open(plt_file, "r") as f:
plot = f.read()
# self.plot_web_view.setContent(plot)
url = QUrl(plt_file)
self.plot_web_view.setHtml(plot, url)
但是当我使用 WinPyhton
分发我的应用程序时,我的绘图不会显示在 QWebView
中并且不会引发错误...如果我尝试加载随机 html-文件到我的应用程序中的 QWebView
中,它们会显示出来.我想问题出在 Qt
方面,但我不知道该怎么办......
But when I distribute my application using WinPyhton
my plot doesn't show up in QWebView
and no error is raised... If I try to load random html-files into QWebView
in my app they are displayed. I guess the issue is on Qt
side, but I have no clue what to do...
WinPython
中的PyQt
版本是 5.5.1
PyQt
version in WinPython
is 5.5.1
Bokeh其实是两个库:一个Python库Bokeh"",以及一个 JavaScript 库BokehJS".JavaScript 库 BokehJS 实际上是在浏览器中完成所有工作的,并且是绝对必需的.稍微谷歌搜索就会出现许多链接,包括 this other StackOverflow answer,这似乎表明 QWebView
不加载外部 <script>
标签在 HTML 中.如果是这种情况,您将不得不寻找其他方法来加载所需的 BokehJS 文件.另一种选择可能是使用内联"BokehJS,这可以通过设置环境变量 BOKEH_RESOURCES=inline
当您运行脚本来创建 HTML 文件时.请注意,这会使单独的 HTML 输出文件变得更大(BokehJS 是一个相当庞大的库)并且还会破坏任何缓存现代浏览器执行的外部脚本(但也许 QWebView
没有无论如何都要这样做).
Bokeh is actually two libraries: a Python library "Bokeh
", and a JavaScript library "BokehJS". The JavaScript library BokehJS is actually what does all the work in the browser, and is absolutely required. A little googling turns up many links, including this other StackOverflow answer, which seem to indicated that QWebView
does not load external <script>
tags in HTML. If that is the case, you will have to find some other means to load the required BokehJS files. Another option might be to use "inline" BokehJS, which can be accomplished by one way by setting the environment variable BOKEH_RESOURCES=inline
when you run the scripts to create the HTML files. Please be aware that this will make individual HTML output files substantially larger (BokehJS is a fairly hefty library) and additionally will defeat any caching of external scripts that modern browsers do (but maybe QWebView
doesn't do that anyway).
最后,虽然我确实希望你能找到一条可行的路径,但要明确一点:QWebView
不是受支持"的平台,因为没有进行任何测试来确保 Bokeh 是与 QWebView
兼容,并且不保证与 QWebView
兼容.
Lastly, while I do hope you can find a path that works, just to be clear: QWebView
is not a "supported" platform, in the sense that no testing is done to ensure Bokeh is compatible with QWebView
and no guarantee of compatibility with QWebView
is claimed.
这篇关于QWebView 中不显示散景图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!