pyqt5 使用label控件实时显示时间的实例
作者:窥月 时间:2021-01-29 14:54:17
如下所示:
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显示时间")
self.label = QLabel(self)
self.label.setFixedWidth(200)
self.label.move(90, 80)
self.label.setStyleSheet("QLabel{background:white;}"
"QLabel{color:rgb(300,300,300,120);font-size:10px;font-weight:bold;font-family:宋体;}"
)
# 动态显示时间在label上
timer = QTimer(self)
timer.timeout.connect(self.showtime)
timer.start()
def showtime(self):
datetime = QDateTime.currentDateTime()
text = datetime.toString()
self.label.setText(" "+ text)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
my = showTime()
my.show()
sys.exit(app.exec_())
来源:https://blog.csdn.net/qq_32973061/article/details/81095369
标签:pyqt5,label,时间
0
投稿
猜你喜欢
拖拽翻页(ThrowPage)详解 cool
2009-12-02 09:54:00
python解决循环依赖的问题分析
2023-03-19 12:22:14
python logging类库使用例子
2023-10-31 11:17:11
CSS中写expression可能会在Chrome中有问题
2010-01-29 13:10:00
sqlserver 日期比较、日期查询常用语句:月的第一天,季度的第一天等
2010-08-01 18:58:00
Pandas中根据条件替换列中的值的四种方式
2022-07-25 00:27:38
python numpy 一维数组转变为多维数组的实例
2023-03-19 23:30:10
pandas DataFrame实现几列数据合并成为新的一列方法
2021-05-22 01:36:00
设计原则-控件Balloons(气球状提示)
2009-08-15 12:34:00
JSP页面传参出现中文乱码的解决方案
2023-06-13 12:53:03
详解Python中的from..import绝对导入语句
2022-08-10 10:01:33
IE6 bug: 消失的绝对定位元素
2009-12-04 12:11:00
Django csrf校验的实现
2023-10-01 14:49:40
网页设计:把导航系统做薄
2007-12-28 12:02:00
XML入门精解之文件格式定义
2008-02-25 13:57:00
python使用json序列化datetime类型实例解析
2021-03-03 05:33:40
asp 分页函数,可以显示 1,2,3,4,5... 前十页,后十页,下一页,上一页
2009-07-05 18:34:00
对django layer弹窗组件的使用详解
2021-09-08 00:09:38
asp按关键字查询XML的代码
2011-04-21 11:10:00
golang微服务框架基础Gin基本路由使用详解
2023-07-23 10:31:19