An example of pyqt5 using label control to display time in real time


As follows:

import sys
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
class showTime(QDialog):
  def __init__(self):

    super(showTime, self).__init__()
    self.resize(500, 400)
    Self.setwindowtitle ("label display time")
    self.label = QLabel(self)
    self.label.move(90, 80)
                   "Qlabel {color: rgb (300300300120); font size: 10px; font weight: bold; font family: Tahoma;}"
    #Dynamic display time on the label
    timer = QTimer(self)
  def showtime(self):
    datetime = QDateTime.currentDateTime()
    text = datetime.toString()
    self.label.setText("   "+ text)

if __name__ == '__main__':
  app = QtWidgets.QApplication(sys.argv)
  my = showTime()

The above example of pyqt5 using label control to display time in real time is all the content that Xiaobian shared with you. I hope it can give you a reference, and I hope you can support developepaer more.

Recommended Today

[reading notes] calculation advertising (Part 3)

By logm This article was originally published at and is not allowed to be reproduced~ If the mathematical formula in the article cannot be displayed correctly, please refer to: Tips for displaying the mathematical formula correctly This article isComputing advertising (Second Edition)Reading notes. This part introduces the key technology of online advertising, which is […]