I want to change the font color of a text in an UI, but it's seems that there is nothing in the text command doc to do this. It's possible to change the background color, but nothing about the font itself.
I searched around the internet and found this code to change a button text color using PyQt (source).
import maya.OpenMayaUI as omUI
from PyQt4 import QtGui
import sip
bt = sip.wrapinstance(long(omUI.MQtUtil.findControl(_the_button_name_)), QtGui.QPushButton)
bt.setStyleSheet('QPushButton {color: yellow}')
So, I have two questions:
First, what should I use, instead of QPushButton
, to edit the color of a text control, and two, the button color here is changed to 'yellow'
and I'd like to change it to a custom color value, is there a way to also do this?
Thanks in advance!
when using the setStyleSheet function you are changing the properties of the style with a syntax similar to CSS, so if we want to use a specific color we can pass the values as rgb or hex code as shown below:
You can also apply to any widget without telling you to set the widget as shown below:
For text use the following: