Can Maya's "Window Frame" color be changed?

1,234 views
Skip to first unread message

Chad_Fox

unread,
Sep 26, 2016, 2:46:02 PM9/26/16
to Python Programming for Autodesk Maya
I'm familair with how we can edit Maya's UI color with the window, layout, button commands, but was wonding this morning if there's a way to just change UI border/ window frame colors or title bar colors in python?

The end goal is that I would like to use a slightly different color for each instance of Maya I open up. 

Have any of you tried this before or know where to read up on how?

Thanks!

Marcus Ottosson

unread,
Sep 26, 2016, 3:19:22 PM9/26/16
to python_in...@googlegroups.com

Try this one on for size.

from PySide import QtGui
QtGui.qApp.setStyleSheet("""
QWidget {
    background: steelblue
}
""")

That should give you a good estimate on the level of control you have through stylesheets and the overall Maya interface.

Don’t worry, you can restore it to it’s former glory like this.

from PySide import QtGui
QtGui.qApp.setStyleSheet("")

damon shelton

unread,
Sep 27, 2016, 12:18:20 AM9/27/16
to python_in...@googlegroups.com
I have set this using style sheets for certain elements that most Uis would have. Even made a system that lets users have control over the colors.
I set the style sheet on the maya mainwindow
have not checked the toolbars in 2017 yet
mainwindow is a wrappedinstance - I set the background color of a few items in the maya gui back for personal choice of how overwhelming the colors get because maya utilizes toolBars for some big sections of the main ui

mainwindow.setStyleSheet('QToolBar, QStatusBar, QMenuBar{background-color:rgb(%d, %d, %d);}\nQMainWindow#%s,#toolBar1,#toolBar2,#toolBar3,#toolBar4,#toolBar5,#toolBar6,#toolBar7{background-color:rgb(70,70,70);}'%(splits[0], splits[1], splits[2], mainwindow.objectName()))
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4fdb53f8-7889-41fa-a0e4-cec794907287%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chad_Fox

unread,
Sep 27, 2016, 10:37:36 AM9/27/16
to Python Programming for Autodesk Maya
Thanks for the ideas.

I was asked to add some kind of color indication to help reduce mistakes made when artists have multiple mayas open in Windows (So much easier in Linux with multiple desktops!), but haven't had the chance to train up on using PySide yet. Anyways I think changing the top menuBar color is the solution I'll test out now. At first polling with my co-workers they like this best, thought it worked well and didn't distract.

from PySide import QtGui
QtGui.qApp.setStyleSheet("""
QMenuBar {
    background: rgb( 200, 40, 0 );
   color:          rgb( 255, 255, 255 );
}
""")

The Color setting is to make the text white or change depending on what color the menubar is set to so it can still be readable

Cheers

On Monday, September 26, 2016 at 9:18:20 PM UTC-7, damonshelton wrote:
I have set this using style sheets for certain elements that most Uis would have. Even made a system that lets users have control over the colors.
I set the style sheet on the maya mainwindow
have not checked the toolbars in 2017 yet
mainwindow is a wrappedinstance - I set the background color of a few items in the maya gui back for personal choice of how overwhelming the colors get because maya utilizes toolBars for some big sections of the main ui

mainwindow.setStyleSheet('QToolBar, QStatusBar, QMenuBar{background-color:rgb(%d, %d, %d);}\nQMainWindow#%s,#toolBar1,#toolBar2,#toolBar3,#toolBar4,#toolBar5,#toolBar6,#toolBar7{background-color:rgb(70,70,70);}'%(splits[0], splits[1], splits[2], mainwindow.objectName()))

On Monday, September 26, 2016, Chad_Fox <chadl...@gmail.com> wrote:
I'm familair with how we can edit Maya's UI color with the window, layout, button commands, but was wonding this morning if there's a way to just change UI border/ window frame colors or title bar colors in python?

The end goal is that I would like to use a slightly different color for each instance of Maya I open up. 

Have any of you tried this before or know where to read up on how?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Marcus Ottosson

unread,
Sep 27, 2016, 10:59:51 AM9/27/16
to python_in...@googlegroups.com
Glad it worked out!​

Chad_Fox

unread,
Dec 2, 2016, 8:59:19 PM12/2/16
to Python Programming for Autodesk Maya
Hey, just a quick follow up on this,

The script I posted earlier works, but it is also changing the background and text color of attribute text boxes. When an attr is keyed, locked or connected while this stylesheet change is active, the backgrounds are dark grey and text black.

Thoughts on why that might be?

fruity

unread,
Jan 12, 2017, 2:57:36 PM1/12/17
to Python Programming for Autodesk Maya
Hi Chad,

You can do it easily using something like

cmds.colorEditor()
targetWindows = ['mainWindow', 'graphEditor', etc...]
if cmds.colorEditor(q=1, result=1): 
    rgbCol = cmds.colorEditor(q=1, rgb=1)
    uis = cmds.lsUI(windows=1)
    for ui in uis:
        if any([t in ui for t in targetWindows]):
            cmds.window(ui, e=1, bgc=rgbColor)

Or if you want the qt solution, and a better control, what I usually do is getting a pointer to the main window and coloring it with a styleSheet, like so :

objName = mainWindow.objectName()
mainWindow.setStyleSheet('#'+objName+'{background-color: rgb(100, 50, 100)}')

This way (i.e. by giving the object name of your window in the css), your style sheet won't be inherited by all the children !

(Funny, I don't know where you work, but I had the same request from animators in my studio a couple of weeks ago ^^)

Marcus Ottosson

unread,
Jan 13, 2017, 3:58:34 AM1/13/17
to python_in...@googlegroups.com
Hey Chad,

Must have missed your last question.

The reason you're getting more than you ask for with stylesheets, is because they override any "QStyle" already in there. A reason some one might use QStyle, as opposed to stylesheets, is because stylesheets is a high-level wrapper around styles and doesn't cover everything you could think to do with it.

To get the same look, you'll need to reimplement what they have accomplished with styles. Odds are, you'll be mostly successful as stylesheets do cover lots of things. But if unlucky, you'll be unable to replicate some things. Like how in 2016+ the channels change color based on whether there is a key on it or not.

You could then look into using styles, but my experience with it is both short and painful.

Best,
Marcus

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4e398c05-076e-4113-86d2-f6495d576d43%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Chad Fox

unread,
Jan 16, 2017, 3:37:28 PM1/16/17
to python_in...@googlegroups.com

Thanks

​,


I'll investigate both options!​


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBC4XmeMC1iyNqxoYcgCp%2Bvc5GRkujeqkOdxy16RvLMWQ%40mail.gmail.com.

Chad_Fox

unread,
Jan 16, 2017, 9:17:23 PM1/16/17
to Python Programming for Autodesk Maya
Hi All,

So I took a pretty deep dive into Styles and Palettes today. They are very useful for Custom UI, but it looks like I cannot change Maya's base palette with any kind of permanence. I was able to change the Menubar style, but if I clicked out of Maya and back in, everything reset back to the default style.

Do you know If it's possible to change the palette in a maya session and not lost it when you leave? 
 
Thanks

fruity

unread,
Jan 16, 2017, 11:29:00 PM1/16/17
to Python Programming for Autodesk Maya
Weird, what is your environment ? It works correctly for me, and is persistent (not from one maya session to another, but as long as my maya is open, even if I change of app, it's still working. Which makes sense, as the widgets are still the same.

Chad_Fox

unread,
Jan 18, 2017, 12:27:07 AM1/18/17
to Python Programming for Autodesk Maya
Well that's at least good to hear!

We're using the following script to get as far as changing the menubar color. It changes the main windows full menubar bg color, but only the bg of the text of all other menus.. not ideal, but better than using stylesheets which mess up Maya dynamic colors on attributes like I mentioned before.


from PySide import QtGui, QtCore
 
base_palette = QtGui.QPalette()
MENU_COLOR = QtGui.QColor(50, 170,20)
base_palette.setBrush(QtGui.QPalette.Background, QtGui.QBrush(MENU_COLOR))
QtGui.QApplication.setPalette(base_palette, 'QMenuBar')


It's very likely we are just missing something fundamentally important. My colleague and I working on this are still new to Styles and Palettes.

Let us know if you see the issue with our attempt at color changing.. we'd love to have this NOT reset when we leave maya. lol 

Info: We're using Maya 2015, 2016ex1, 2016ex2 on windows 7 and 10 and have the same results in each.
Reply all
Reply to author
Forward
0 new messages