Up to Maya 2019 I was using the following script to customize the script editor font.
from PySide2 import QtGui, QtCore, QtWidgets
def set_font(font='Courier New', size=12):
"""
Sets the style sheet of Maya's script Editor
"""
# Find the script editor widget
app = QtWidgets.QApplication.instance()
win = next(w for w in app.topLevelWidgets() if w.objectName()=='MayaWindow')
# Add a custom property
win.setProperty('maya_ui', 'scriptEditor')
# Apply style sheet
styleSheet = '''
QWidget[maya_ui="scriptEditor"] QTextEdit {
font-family: %s;
font: normal %spx;
}
''' %(font, size)
app.setStyleSheet(styleSheet)
And with this I could change the script editor's font style and size uniformly across all tabs.
# this is my current favorite
set_font(font='Consolas', size=20)
In Maya 2018 and 2019 this works fine. I have not tested 2020, but in 2022 and 2023 it executes without errors but fails to change the interface as desired.
QUESTION
What has changed since 2019 that would make this script fail. Any tip on how to make this script work would be greatly appreciated. Otherwise I'll post a solution here when I find the issue.