Announcements

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

Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maya ver 2019 - 2023 crash during basic PySide2 exec

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
thecococheena
415 Views, 3 Replies

Maya ver 2019 - 2023 crash during basic PySide2 exec

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

3 REPLIES 3
Message 2 of 4
Kahylan
in reply to: thecococheena

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!

Message 3 of 4
thecococheena
in reply to: Kahylan

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

Regards,

-Cash
Message 4 of 4
thecococheena
in reply to: Kahylan

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.

Post to forums  

Autodesk Design & Make Report