【问题标题】:PyQt5: QWebEngineView can't render local html file in Windows 7PyQt5:QWebEngineView 无法在 Windows 7 中呈现本地 html 文件
【发布时间】:2016-12-04 14:38:30
【问题描述】:

我正在使用 QWebEngineView 构建一个 PyQt5 应用程序。 html 文件由 BeautifulSoup 读取,美化它然后使用 QtWebEngineView 显示它。我的代码如下:

class HTMLRenderer(QWebEngineView):

     def __init__(self):
          super(HTMLRenderer, self).__init__(parent)
          self.soup = BeautifulSoup(open('../template/email.html', 'r').read(), 'html.parser')
          self.render()

     def render(self):
          self.setHtml(self.soup.prettify())
          self.show()

但是 QtWebEngineView 是空白的。它无法显示任何内容。

我正在 Windows 7 上开发。整个代码在 Mac OS 上运行。但现在我想让它在 Windows 7 上运行。

QWebEngineView 在 Windows 上好像有问题。

感谢您的建议。

【问题讨论】:

    标签: python qt pyqt


    【解决方案1】:

    我设法通过粘贴整个 url 路径来“跳过”这个错误。似乎没有渲染相对路径。

    【讨论】:

      猜你喜欢
      • 2020-09-25
      • 2022-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-28
      • 1970-01-01
      相关资源
      最近更新 更多