Advertisement
jhongesell

Reloj digital con ícono hecho en PyQt5

Oct 16th, 2018
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. from PyQt5.QtWidgets import (
  2.     QApplication,
  3.     QLCDNumber
  4. )
  5.  
  6. from PyQt5.QtCore import (
  7.     QTimer,
  8.     QTime
  9. )
  10.  
  11. from PyQt5.QtGui import QIcon
  12.  
  13. class Clock(QLCDNumber):
  14.  
  15.     def __init__(self, digits=8, parent=None):
  16.         super(Clock, self).__init__(digits, parent)
  17.         self.setWindowTitle("Reloj Digital")
  18.         self.setWindowIcon(QIcon("mydigitalclock.png"))
  19.         # Timer
  20.         self.timer = QTimer()
  21.         # Connect timer
  22.         self.timer.timeout.connect(self._update)
  23.         # Start
  24.         self.timer.start(1000)
  25.  
  26.     def _update(self):
  27.         """ Update display each one second"""
  28.  
  29.         time = QTime.currentTime().toString()
  30.         self.display(time)
  31.  
  32.  
  33. if __name__ == "__main__":
  34.     import sys
  35.  
  36.     app = QApplication([])
  37.  
  38.     w = Clock()
  39.     w.show()
  40.     w.resize(300, 100)
  41.  
  42.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement