salah
salah

Reputation: 106

how to make blinking label or widget with pyqt4

Hi i would like to know if we can make a label blinking with pyqt 4 my goal is to create a waring label , saying waring missing folder and make it blinking I dont have any code and I am new with PyQt if it not label it can be widget or anything please not message box and thanks for the help

Upvotes: 1

Views: 2331

Answers (1)

Rhdr
Rhdr

Reputation: 387

Disclaimer: I have pyqt5 installed and converted it to pyqt4 without testing it in pyqt4...

class MyForm(QtGui.QWidget):
    def __init__(self, parent = None):
        super(MyForm, self).__init__(parent)
        self.lbl = QtGui.QLabel("Clock", self)
        self.lbl.setAlignment(QtCore.Qt.AlignCenter)
        self.lblHidden = False

        vLayout = QtGui.QVBoxLayout(self)
        vLayout.addWidget(self.lbl)
        self.setLayout(vLayout)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.flashLbl)
        timer.start(1000)

    def flashLbl(self):
        if self.lblHidden == False:
            self.lbl.hide()
            self.lblHidden = True
        else:
            self.lbl.show()
            self.lblHidden = False

Upvotes: 4

Related Questions