css issue

   820   0   0
User Avatar
Member
1 posts
Joined: Aug. 2018
Offline
Hi,


I am implementing a gui to sanitize our scenes in all our DCCs including Houdini. I need the the color of a progress bar to change depending on the result of the sanity.
I use Qt and the exact same code in all the DCCs.

The problem is that I get a different result executing the code from the source editor than from the python panel.
Is there any way I can remove the css overload ?

this is the code :

from PySide2 import QtWidgets, QtGui, QtCore

class CustomProgressbar(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(CustomProgressbar, self).__init__(parent=parent)

    def paintEvent(self, event):
        painter  = QtGui.QPainter(self)

        progressBar = QtWidgets.QStyleOptionProgressBar()
        progressBar.state = QtWidgets.QStyle.State_Enabled
        progressBar.direction = QtWidgets.QApplication.layoutDirection()
        progressBar.rect = QtCore.QRect(50, 50, 200, 50)
        progressBar.fontMetrics = QtWidgets.QApplication.fontMetrics()
        progressBar.minimum = 0
        progressBar.maximum = 100
        progressBar.textAlignment = QtCore.Qt.AlignCenter
        progressBar.textVisible = True
        progressBar.progress = 50
        progressBar.palette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(0, 0, 255))
        progressBar.text = "CRITICAL"
        QtWidgets.QApplication.style().drawControl(
            QtWidgets.QStyle.CE_ProgressBar, progressBar, painter)
    
progress_bar = CustomProgressbar()
progress_bar = QtWidgets.QProgressBar()
progress_bar.setValue(50)
progress_bar.setStyleSheet("""chunk {
    background-color: #FF0000;
    width: 10px;
    margin: 0.5px;
}""")
QtWidgets.QApplication.setStyleSheet(QtWidgets.QApplication.instance(), """QProgressBar::chunk {
    background-color: #FF0000;
    width: 10px;
    margin: 0.5px;
}""")
progress_bar.show()

Attachments:
houdini_css.png (47.4 KB)

  • Quick Links