I would like to know how I can make the self.show() instruction at the end of my Vispy.app.Canvas init() dependant on the fact the canvas is basically run in a Vispy app or as a QWidget in a QMainWindow.
So I have a Python3 Vispy app that run and shows directly a Canvas. At the end of the init call of the Canvas, there is a mandatory self.show(). This works fine.
Now I want to use also this canvas as the central widget in a QMainWindow. This works ONLY if I comment out the self.show() command.
I would like to make this call dependant of something (canvas.native.parent... or something, to execute it only when run outside of a QMainWindow:
if SOME_CONDITION_TELLING_ME_I_M_OUT_OF_QMAINWINDOW:
self.show()
This would help me factorize this canvas class instead of having two versions just for this self.show() call.
I hope this very first question is clear.
Full code available here: https://github.com/gregvds/grayscott
Thanks,
Greg
You don't need to have the self.show()
in the __init__
method of the class. You could call it from the module that is using it, after the Canvas is created:
canvas = Canvas(...)
canvas.show()
That way you only need to call .show()
from the uses where the Canvas is its own window.