How to add a callback to MC.warning to update commandLine1 QLineEdit background color ?

33 views
Skip to first unread message

oglop

unread,
Jul 26, 2017, 2:07:25 PM7/26/17
to Python Programming for Autodesk Maya
This is supposed to be a workaround, because I enlarged maya ui fonts with 

from Qt import QtGui
import maya.cmds as MC

styleSheet = '''

* {
  font: 13px;
}

QTextEdit,QMenu {
    font-family: "Courier New";
    font: normal 16px;

}

'''

app = QtGui.QApplication.instance()
app.setStyleSheet(styleSheet)

# This does not show yellow background color anymore
MC.warning('something')

Or am I doing something wrong with the stylesheet ? I tried  :not(QSplitter QLineEdit) to exclude it, but it has no effect ( still always dark color ) 

Michael Boon

unread,
Jul 26, 2017, 8:57:56 PM7/26/17
to Python Programming for Autodesk Maya
Marcus and Justin are much more knowledgeable about stylesheets than I am, but, I suspect you just need to set the stylesheet on the main window instead of the QApplication instance. 

The example on this page sets a color, but I think the same approach should work for you:
http://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__files_GUID_3F96AF53_A47E_4351_A86A_396E7BFD6665_htm

Andres Weber

unread,
Jul 27, 2017, 5:26:11 PM7/27/17
to Python Programming for Autodesk Maya
I don't have an answer for the stylesheet issue which seems like an interesting formatting problem...however I found a workaround (that I haven't tested really) that does not involve stylesheets but keeps the existing stylesheet rules intact:

app = QtWidgets.QApplication.instance()
font = QtGui.QFont()
font.setPointSize(16)
app.setFont(font)

Justin Israel

unread,
Jul 27, 2017, 5:51:03 PM7/27/17
to Python Programming for Autodesk Maya
I don't have a specific answer right now either. But I would definitely think it is preferable to set the QFont if that works and avoid stylesheets. Stylesheets are heavy handed, because when you override a widget's style it kind of overrides *everything* so you have to be really complete in defining all the attributes.

Justin


--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a265f0bb-ff6f-40f0-8e46-ab09e02cdb90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages