2

enter image description here

I have message response as you see on the above. I've managed to colour background to black:

msg.setStyleSheet("background-color: rgb(0, 0, 0);")

I've tried with same way for the text but it looks like this:

enter image description here

msg.setStyleSheet("text-color: rgb(255, 255, 255);")

My only purpose is texts are white and background is black...

Here is my part of code:

msg = QMessageBox()
msg.setText("Message has been sended")
msg.setWindowTitle("SENT")
msg.setWindowIcon(QtGui.QIcon("black tic.png"))
msg.setIcon(QMessageBox.Information)
msg.setStyleSheet("background-color: rgb(0, 0, 0);")
msg.setStyleSheet("text-color: rgb(255, 255, 255);")
msg.exec_()
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Twister Joe
  • 111
  • 2
  • 11

3 Answers3

2

To change the color of the text of a QMessageBox, you have to use the following line

msgBox.setStyleSheet("QLabel{ color: white}");
barbsan
  • 3,418
  • 11
  • 21
  • 28
Sara
  • 119
  • 7
0

Try this one, it works fine...

msg.setStyleSheet("color:white;background:black")
0
msg = QMessageBox()
msg.setText("Message has been sended")
msg.setWindowTitle("SENT")
msg.setWindowIcon(QtGui.QIcon("black tic.png"))
msg.setIcon(QMessageBox.Information)
msg.setStyleSheet("background-color: rgb(0, 0, 0);color: rgb(255, 255, 255);")
msg.exec_()
RiveN
  • 2,595
  • 11
  • 13
  • 26
ak 07
  • 1