Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Maya ver 2019 - 2023 crash during basic PySide2 exec

thecococheena
Explorer
Explorer

Maya ver 2019 - 2023 crash during basic PySide2 exec

thecococheena
Explorer
Explorer

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

0 Likes
Reply
Accepted solutions (1)
415 Views
3 Replies
Replies (3)

Kahylan
Advisor
Advisor
Accepted 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!

0 Likes

thecococheena
Explorer
Explorer
Thank you for the response. I’ll clear it up and get back to the thread
tomorrow!

Regards,

-Cash
0 Likes

thecococheena
Explorer
Explorer

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

0 Likes