好的,我应该找到问题所在。
似乎QWebView加载本地文件有些困难,因为它太重了(简单绘图大约2mb)。
所以我用的选项, 包括javascript
保存本地文件时,并加载javascript
在第二时刻的感谢,作为描述在这里。
换句话说,创建初始的html标签,包括通过plotly生成的图形结果而没有整个javascript代码,并包括javascript的链接。
这样,文件非常轻便,QWebView
没有问题可以打开它。
# create the initial html code
raw_html = '<head><Meta charset="utf-8" /></head>''<head><Meta charset="utf-8" /><script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>'
# call the plot method without all the javascript code
raw_html += plotly.offline.plot(fig, filename = fn, include_plotlyjs=False)
# close the body and html tags
raw_html += '</body></html>'