如何在 PySide2 应用程序中嵌入 matplotlib 画布 [英] How to embed matplotlib canvases in a PySide2 application

查看:177
本文介绍了如何在 PySide2 应用程序中嵌入 matplotlib 画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 matplotlib 画布嵌入到 PySide2 应用程序中.我尝试使用以下示例: https://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html

I am trying to embed a matplotlib canvas into a PySide2 application. I have tried to use this example: https://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html

该示例使用 PyQt5 运行良好.但是,如果我将第 19 行更改为

The example runs fine using PyQt5. However, if I change line 19 from

from PyQt5 import QtCore, QtWidgets

进入

from PySide2 import QtCore, QtWidgets

然后Python崩溃并显示消息

then Python crashes with the message

致命的Python错误:取消分配无

Fatal Python error: deallocating None

应用程序窗口关闭时.有没有办法使用 PySide2 使其正常工作?

as soon as the application window is closed. Is there any way to get this working properly using PySide2?

推荐答案

事实证明,这是PySide2中的一个错误,现已修复(请参见

It turns out that this was a bug in PySide2, which now has been fixed (see https://bugreports.qt.io/browse/PYSIDE-632?gerritReviewStatus=All). Just update to the most current version to get rid of the problem.

这篇关于如何在 PySide2 应用程序中嵌入 matplotlib 画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆