Skip to content

Instantly share code, notes, and snippets.

@oglops
Created February 16, 2016 08:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oglops/e9cff88984e4f9b277ed to your computer and use it in GitHub Desktop.
Save oglops/e9cff88984e4f9b277ed to your computer and use it in GitHub Desktop.
set script editor font for maya
# You can put this inside your userSetup.py
# import maya.utils as mu
# import script_editor_font as SE
# mu.executeDeferred(SE.launchFromCmdWndIcon)
from PyQt4 import QtGui, QtCore
from maya import cmds, mel
import maya.OpenMayaUI as apiUI
import sip
def launchFromCmdWndIcon():
'''launch from maya command line script editor icon.'''
def cmdWnd(arg=None):
cmds.ScriptEditor()
set_script_editor_font()
# get command line formLayout
gCommandLineForm = mel.eval('$tempVar = $gCommandLineForm')
commandLineForm = cmds.formLayout(gCommandLineForm, q=1, ca=1)[0]
# get cmdWndIcon button
cmdWndIcon = cmds.formLayout(commandLineForm, q=1, ca=1)[-1]
# change the command of the button
cmds.symbolButton(cmdWndIcon, e=1, c=cmdWnd)
# change the main manu item command
menuName = 'wmScriptEditor'
if cmds.menuItem(menuName, q=1, ex=1):
cmds.menuItem(menuName, e=1, c=cmdWnd)
def getMayaWindowWidget():
'another of finding main maya window'
ptr = apiUI.MQtUtil.mainWindow()
mwin = sip.wrapinstance(long(ptr), QtCore.QObject)
return mwin
def set_script_editor_font():
'set stylesheet on all qtextedit inside script editor window'
# find script editor qwidget
ptr = apiUI.MQtUtil.findControl('scriptEditorPanel1Window')
win = sip.wrapinstance(long(ptr), QtCore.QObject)
# add a custom property to it
win.setProperty('maya_ui', 'scriptEditor')
# apply stylesheet to any qtextedit inside script editor qwidget
# you can use any cool fonts here
styleSheet = '''
QWidget[maya_ui="scriptEditor"] QTextEdit {
font-family: "Courier New";
font: normal %spx;
}
''' % '16'
app = QtGui.QApplication.instance()
app.setStyleSheet(styleSheet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment