Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
Dear Forum,
I am seeing a repeated crash without fail while running the following script screen captured below. Are there any fixes to this issue and why I am experiencing a crash?
This code is directly from the "Creat GUI Applications with Python & Qt5" book by Martin Fitzpatrick.
Any insight would be helpful. Thanks for your time.
Regards,
-Cash
Solved! Go to Solution.
Solved by Kahylan. Go to Solution.
Hi!
Thats because this code is meant to be run from a terminal. If you are inside the Maya UI you already have an instance of QApplication, so you don't have to do it yourself. Doing it again will cause the two versions of QApplications to have conflicts and Maya to crash.
You should instead just instance the version of QApplication that already exists to bind it to your variable.
from PySide2.QtWidgets import QApplication, QMainWindow
import sys
app = QApplication.instance()
window = QMainWindow()
window.show()
app.exec_()
I hope it helps!
It worked like a charm. What you said made sense. I had no idea that was one of the little things with PySide2 that I needed to be aware of inside Maya. Thank you very much and I hope you have a wonderful day!
Regards,
-Cash
Can't find what you're looking for? Ask the community or share your knowledge.