问题描述
我正在尝试将 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错误:取消分配无
应用程序窗口关闭时.有没有办法使用 PySide2 使其正常工作?
as soon as the application window is closed. Is there any way to get this working properly using PySide2?
推荐答案
事实证明,这是PySide2中的一个错误,现已修复(请参见 https://bugreports.qt.io/browse/PYSIDE-632?gerritReviewStatus=All ).只需更新到最新版本即可解决问题.
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 画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!