2022-04-12 21:34:18 +08:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
from PyQt5.QtGui import QFont
|
|
|
|
from PyQt5.QtWidgets import *
|
|
|
|
|
|
|
|
|
|
|
|
class HeadLabel(QLabel):
|
|
|
|
def __init__(self):
|
|
|
|
super(HeadLabel, self).__init__()
|
2022-04-13 21:42:41 +08:00
|
|
|
self.setScaledContents(True)
|
2022-04-12 21:34:18 +08:00
|
|
|
self.setObjectName('head_label')
|
|
|
|
layout = QVBoxLayout()
|
2022-04-16 21:45:29 +08:00
|
|
|
# self.setMinimumHeight(170)
|
2022-04-12 21:34:18 +08:00
|
|
|
|
|
|
|
# 设置当前时间
|
|
|
|
weekday = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
|
|
|
|
weekday_index = datetime.now().weekday()
|
|
|
|
month = datetime.now().month
|
|
|
|
day = datetime.now().day
|
|
|
|
|
|
|
|
# 输出日期示例
|
|
|
|
# print(str(month) + '月' + str(day) + '日,' + weekday[weekday_index])
|
|
|
|
|
|
|
|
self.title = QLabel("我的一天")
|
2022-04-14 16:19:59 +08:00
|
|
|
self.title.setStyleSheet('font-weight:bold;color:white;margin:0px')
|
|
|
|
# self.title.setObjectName('title')
|
2022-04-12 21:34:18 +08:00
|
|
|
# 设置字体大小
|
|
|
|
self.font = QFont()
|
2022-04-18 21:18:08 +08:00
|
|
|
self.font.setPointSize(26)
|
2022-04-12 21:34:18 +08:00
|
|
|
self.title.setFont(self.font)
|
2022-04-14 16:19:59 +08:00
|
|
|
# todo: 需要调整布局,修复字体间距
|
2022-04-12 21:34:18 +08:00
|
|
|
|
2022-04-13 21:42:41 +08:00
|
|
|
# self.title.setObjectName('title')
|
2022-04-12 21:34:18 +08:00
|
|
|
self.time_label = QLabel(str(month) + '月' + str(day) + '日,' + weekday[weekday_index])
|
2022-04-18 21:18:08 +08:00
|
|
|
self.time_label.setStyleSheet('color:white;margin:0px')
|
2022-04-14 16:19:59 +08:00
|
|
|
|
2022-04-13 21:42:41 +08:00
|
|
|
# self.time_label.setObjectName('time_label')
|
2022-04-12 21:34:18 +08:00
|
|
|
layout.addWidget(self.title)
|
|
|
|
layout.addWidget(self.time_label)
|
|
|
|
self.setLayout(layout)
|
|
|
|
self.show()
|