Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1.  
  2. from PyQt5.QtCore import QTimer
  3. from PyQt5.QtWidgets import QLabel
  4. from PyQt5.QtCore import pyqtSlot
  5.  
  6. class QBlinkLabel(QLabel):
  7.     """Мигающий QLabel"""
  8.     def __init__(self, parent):
  9.         super(QBlinkLabel, self).__init__()
  10.  
  11.         self.status = True
  12.         self.blink_color_one = None
  13.         self.blink_color_two = None
  14.  
  15.     def startBlink(self, color_one, color_two):
  16.         self.blink_color_one = "background-color: {};".format(color_one)
  17.         self.blink_color_two = "background-color: {};".format(color_two)
  18.  
  19.     def stopBlink(self, color_one):
  20.         self.blink_color_two = None
  21.         self.setStyleSheet("background-color: {};".format(color_one))
  22.  
  23.     def setColor(self, color):
  24.         self.setStyleSheet("background-color: {};".format(color))
  25.  
  26.     @pyqtSlot()
  27.     def update_color(self):
  28.         if self.blink_color_two is not None:
  29.             if self.status:
  30.                 self.setStyleSheet(self.blink_color_one)
  31.             else:
  32.                 self.setStyleSheet(self.blink_color_two)
  33.             self.status = not self.status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement