Adverti horiz upsell
Color syntaxing the Script Editor Reporter
Color syntaxing the Script Editor Reporter
mlouala, updated 2017-04-16 11:20:08 UTC 5,762 views  Rating:
(1 rating)
Page 5 of 5

 

Bonus

Here is a little example of a more advanced use of PyQt, this will assign directly the Maya's Python color syntax to the scriptEditor history, you'll just need to use what we've learned above to make it automatic ! I trust you =)

1
2
3
4
5
6
7
8
9
10
11
12
13
from PySide.QtCore import *
from PySide.QtGui import *
from shiboken import wrapInstance as wrapinstance
 
from maya.OpenMayaUI import MQtUtil
 
se_repo = wrapinstance(long(MQtUtil.findControl('cmdScrollFieldReporter1')), QTextEdit)
tmp = cmds.cmdScrollFieldExecuter(sourceType='python')
se_edit = wrapinstance(long(MQtUtil.findControl(tmp)), QTextEdit)
se_edit.nativeParentWidget()
se_edit.setVisible(False)
high = se_edit.findChild(QSyntaxHighlighter)
high.setDocument(se_repo.document())

 

Maya 2017 implementation

The main difference between previous versions of Maya and the last one in date (2017), is that they updated the core to from PySide to PySide2, so, the (super) simple workaround to get the above scripts working in 2017 is ;

1
2
3
4
5
6
7
8
9
try:
    from shiboken import wrapInstance as wrapinstance
    from PySide.QtCore import *
    from PySide.QtGui import *
except ImportError:
    from shiboken2 import wrapInstance as wrapinstance
    from PySide2.QtCore import *
    from PySide2.QtWidgets import *
    from PySide2.QtGui import *

 Basically PySide2 now uses Qt5 core instead of the previous Qt4, the main difference is that the module QtGui which was containing every Qt's visual tools has been splitted between QtWidgets (this one now contains all the 'physical' widgets visible in your UI) and QtGui (this one contains all the abstract methods for visual representation, such as QColor, QBrush, etc)

 

May the peace be with you