PySide2/PyQt5 troubles and advice needed

435 views
Skip to first unread message

Benjam901

unread,
Jan 26, 2017, 9:27:57 AM1/26/17
to Python Programming for Autodesk Maya
Hello all, long time no post!

I am migrating our studio over to Maya2017 and am having some trouble with the first hurdle of transferring from PyQt4 over to PyQt5.

Firstly our studio bootstrap for Maya2015 overrides the Maya built in PySide and uses standard PyQt4 across the whole setup. 
I have been trying to run pip install pyqt or qt5 etc. and nothing is happening, I read on stack overflow that PyQt5 does not support python 2.7 for windows?

If I could replicate the PyQt4 override for Maya2017 with Qt5 that would be great although I have a feeling it won't be that easy, another problem is the entire codebase which included generic python tools use the same methods for adding items, clearing lists, creating widgets etc. If I went over to PySide2 for Maya then I would have to replicate all common methods and include PySide2 only methods which I would rather avoid.

Can anyone tell me if it is possible to get PyQt5 for windows python 2.7 and any other advice for making this switch would be gratefully recieved.

Cheers,

Ben

Nicolas Chaverou

unread,
Jan 26, 2017, 9:46:44 AM1/26/17
to python_in...@googlegroups.com
On Thu, Jan 26, 2017 at 3:27 PM, Benjam901 <benandr...@gmail.com> wrote:
Can anyone tell me if it is possible to get PyQt5 for windows python 2.7 and any other advice for making this switch would be gratefully recieved.


This could be a good start:

i'll recommend taking a look at this Qt.py the nice library from Marcus Ottosson and Fredrik Averpil:
 

Benjam901

unread,
Jan 26, 2017, 9:54:38 AM1/26/17
to Python Programming for Autodesk Maya
Cool thanks man, I am looking at the Qt stuff now it could be a real nice solution to my problem :)

Benjam901

unread,
Jan 27, 2017, 8:02:25 AM1/27/17
to Python Programming for Autodesk Maya
Qt.py seems to be the best option and looks to be an absolute life saver except for one minor detail:

We get the statusline in Maya to place our tool icons so they are easily accessible for users to press:


def getMayaStatusLine():
 
""" Get status line for adding toolbar icons """
 gStatusLine
= mel.eval('$temp=$gStatusLine')
 ptr
= apiUI.MQtUtil.findControl(gStatusLine)
 
if ptr is not None:
 
return sip.wrapinstance(long(ptr), QtWidgets.QWidget)


.setText("")
 btn
.setIcon(icon)
 btn
.setMinimumSize(btnSize)
 btn
.setMaximumSize(btnSize)
 btn
.setIconSize (iconSize)
 btn
.released.connect(callback)

 statusLine
.layout().addWidget(btn)



This thread: https://github.com/mottosso/Qt.py/issues/53 points me in the right direction in getting the main Maya window which is cool but not the status line.


Any tips on how to get the status line using Qt.py, I have tried the below solution as provided by Marcus replacing "MayaWindow" with "StatusLine" but it appears there are a number of QWidgets and QMenus without object names and I think Statusline is one of them


from Qt import QtWidgets
app = QtWidgets.QApplication.instance()
window = {o.objectName(): o for o in app.topLevelWidgets()}["MayaWindow"]
channel_box = window.findChild(QtWidgets.QTableView, "mainChannelBox")
channel_box.setStyleSheet("QWidget {background: green}")

Cheers,

Ben

Benjam901

unread,
Jan 27, 2017, 9:50:56 AM1/27/17
to Python Programming for Autodesk Maya
I found a good gist online for what I am after in case anyone needs it:

def getMayaStatusLine():
 gStatusLine
= mel.eval('$temp=$gStatusLineForm')
 ptr
= apiUI.MQtUtil.findControl(gStatusLine)
 
print ptr
 
if ptr is not None:
 statusLine
= shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)
 
return statusLine.children()[1].children()[1]

Reply all
Reply to author
Forward
0 new messages