i am trying to change the color of a button when is press, and look like it can be done directly with in the stylesheet with out to do a function and then connect it.
in http://qt.developpez.com/doc/4.7-snapshot/stylesheet-examples/ show this example:
QPushButton#evilButton {
background-color: red;
border-style: outset;
border-width: 2px;
border-radius: 10px;
border-color: beige;
font: bold 14px;
min-width: 10em;
padding: 6px;
}
QPushButton#evilButton:pressed {
background-color: rgb(224, 0, 0);
border-style: inset;
}
how can translate that to python pyqt?
i was able to make it work like this, that way the color button is blue and when is press changes to red
btn_text = QString("this font color")
btn = QPushButton(btn_text)
btn.setStyleSheet("QPushButton { background-color: blue }"
"QPushButton:pressed { background-color: red }" )
No translation needed, it is a stylesheet: a text document used by qt (and therefore by pyqt, since pyqt calls qt). For example:
self.groupBox.setStyleSheet("""
QGroupBox
{
background-color: rgb(255, 255,255);
border:1px solid rgb(255, 170, 255);
}
"""
)
Take a look at http://vimeo.com/50033293.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With