I am trying to embed a visual plot (more precisely, Vispy SceneCanvas) as a QWidget in PyQt4. I would suggest that the answer would be something like this:
from PyQt4.QtCore import * from PyQt4.QtGui import * import vispy.mpl_plot as plt app = QApplication(sys.argv) win = QMainWindow() plt.plot([1,2,3,4], [1,4,9,16]) vispyCanvas=plt.show()[0] win.setCentralWidget(vispyCanvas)
However, when I try to do this, the last line gives me the expected error that vispyCanvas is a SceneCanvas type and not a QWidget type. When I print(vispyCanvas) , it outputs <Vispy canvas (PyQt4 (qt) backend) at 0x142bcb00L> , so I suspect that it can be considered either one of its attributes as a QWidget object.
source share