Using PySide2.QtGui from mayapy.exe

242 views
Skip to first unread message

Lidia Martinez

unread,
Mar 1, 2017, 7:08:54 AM3/1/17
to python_in...@googlegroups.com
Hi folks,

I was a little confused when I tried this (something I think I did some time ago)... I saw that mayapy Python interactive interpreter doesn't have any other Qt module loaded but QtCore for PySide2. (I'm in maya 2017). I thought I could use QtGui and QtWidgets from there but it's not available.

Is there any way to create a QApplication from here?


Thanks
--
Lidia

Lidia Martinez

unread,
Mar 1, 2017, 7:10:13 AM3/1/17
to python_in...@googlegroups.com
In fact, Cesar, if there's a chance you see this, in your script over here:
https://gist.github.com/csaez/599c321d7b2cc4a3ff40

We couldn't use this script from mayapy.exe right now, since QtGui is not available. No idea if this used to work on Maya < 2017

--
Lidia

Cesar Saez

unread,
Mar 1, 2017, 8:43:07 AM3/1/17
to python_in...@googlegroups.com
Hi Lidia,

That gist is not intended to work with PySide2 (pre-maya 2017, qt5 implies a few changes).

Here's a very simplistic approach to make a GUI work with multiple versions of maya (not involving 3rd party libraries): https://github.com/csaez/quicklauncher/blob/master/quicklauncher.py#L29

Does that "trick" work for you?

Cheers,
C.

Marcus Ottosson

unread,
Mar 1, 2017, 9:02:21 AM3/1/17
to python_in...@googlegroups.com

This works for me, Maya 2017 on Windows.

$ mayapy
>>> import sys
>>> from PySide2 import QtWidgets
>>> app = QtWidgets.QApplication(sys.argv)
>>> button = QtWidgets.QPushButton("Press me")
>>> button.show()
>>> app.exec_()

Reply all
Reply to author
Forward
0 new messages