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
Author: mlouala
Submitted: 2017-01-07 07:22:24 UTC
Tags: Color, script editor, syntax, script, and syntax highlighting
Software: Maya
Views: 5,762
Related Items
-
Universal UV Randomization script for Maya 1.1.0 (maya script)
$20.00 (USD) -
Render Window / viewport Batch Render Script for Maya 1.0.0 (maya script)
$20.00 (USD) -
UV Texture Editor Tools Ur-edition for Maya 2.1.2 (maya script)
$39.00 (USD) -
Nightshade UV Editor Pro for Maya 2.1.3 (maya script)
$39.90 (USD) -
Christmas Color Ball 3D Model
$20.00 (USD) -
3D Thumbnail Generator (batch script) for Maya 0.3.1 (maya script)
$20.00 (USD) -
Attr Editor for Maya 1.3.0 (maya script)
$25.00 (USD) -
Color T-Shirt 3D Model
$38.00 (USD) -
Samsung Galaxy S6 All Color Pack 3D Model
$49.99 (USD)