Customizing Autodesk Maya Script Editor Using Python and PySide2
The Script Editor that comes shipped with Autodesk Maya is a useful programming tool and I use it professionally at my office.
In the screenshot below you can see the default layout of the widgets
- Menubar
- Tool Icons
- Output console
- Tabbed text areas for writing MEL and Python code.
As you can clearly see, the layout of the widgets is vertical (the tabbed widget below the output console) and when I am writing lots of code in the Script Editor, I see myself scrolling a lot in the text area.
Clearly, a better UX is achieved by the tabbed text areas and the output console next to each other (in a horizontal alignment).
So, I decided to address this by making use of PySide2 Qt Python API that comes shipped with Maya.
Following is the code that I concocted to help me have a better UX with the Script Editor.
import pymel.core as pm
from PySide2 import QtCore
from PySide2 import QtWidgetspanel = pm.getPanel(wf=True)
qtpanel = panel.asQtObject()menuBar, mainWidget = qtpanel.children()[1:]
seww = mainWidget.layout().itemAt(1).widget()
sewww = seww.children()[-1]splitter = sewww.children()[1]
splitter.setOrientation(QtCore.Qt.Orientation.Horizontal)script_console = splitter.widget(0)
script_editor = splitter.widget(1)splitter.insertWidget(0, script_editor)
se_splitter = script_editor.children()[1]
editor = se_splitter.children()[1]
tabWidget = editor.children()[1]tabWidget.setTabPosition(QtWidgets.QTabWidget.TabPosition.South)
After running the script above in the Maya Script Editor, the user-interface is modified as below.
- The script editor and the output console are aligned horizontally.
- The script editor tabs are aligned at the bottom.
I need to run the script every time I reopen the Script Editor, but I am okay with it. I do not think I can change this behavior without actually modifying the UI MEL scripts that come shipped with Maya (and I do not want to do that)
Now it is again time to continue scripting.
Satish Goda
satishgoda at live dot com