简体   繁体   English

如何在PySide2应用程序中嵌入matplotlib画布

[英]How to embed matplotlib canvases in a PySide2 application

I am trying to embed a matplotlib canvas into a PySide2 application. 我正在尝试将matplotlib画布嵌入PySide2应用程序中。 I have tried to use this example: https://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html 我尝试使用此示例: https : //matplotlib.org/examples/user_interfaces/embedding_in_qt5.html

The example runs fine using PyQt5. 使用PyQt5,该示例运行良好。 However, if I change line 19 from 但是,如果我将第19行从

from PyQt5 import QtCore, QtWidgets

into 进入

from PySide2 import QtCore, QtWidgets

then Python crashes with the message 然后Python崩溃与消息

Fatal Python error: deallocating None 致命的Python错误:取消分配无

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 ). 事实证明,这是PySide2中的错误,现已修复(请参阅https://bugreports.qt.io/browse/PYSIDE-632?gerritReviewStatus=All )。 Just update to the most current version to get rid of the problem. 只需更新到最新版本即可解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM