31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
import os
|
||
import sys
|
||
from PyQt5.QtGui import *
|
||
from PyQt5.QtWidgets import *
|
||
from PyQt5.QtCore import Qt
|
||
import datetime
|
||
|
||
|
||
class MyDay(QWidget):
|
||
def __init__(self):
|
||
super(MyDay, self).__init__()
|
||
# 布局样式:最外面一个大的垂直布局,里面的最上面标题是一个水平布局,水平布局显示的是一个垂直布局和一个右边的选项,用来更换背景
|
||
layout = QVBoxLayout()
|
||
head_layout = QHBoxLayout()
|
||
head_left_layout = QVBoxLayout()
|
||
layout.addLayout(head_layout)
|
||
head_layout.addLayout(head_left_layout)
|
||
self.setLayout(layout)
|
||
# todo : 取消这几个不必要的layout,直接重写QLabel实现上面的标签显示,这样不行
|
||
|
||
# 设置当前时间
|
||
weekday = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
|
||
weekday_index = datetime.datetime.now().weekday()
|
||
month = datetime.datetime.now().month
|
||
day = datetime.datetime.now().day
|
||
print(str(month) + '月' + str(day) + '日,' + weekday[weekday_index])
|
||
|
||
self.title = QLabel("我的一天")
|
||
self.time_label = QLabel(str(month) + '月' + str(day) + '日,' + weekday[weekday_index])
|
||
head_left_layout.addWidget(self.title)
|
||
head_left_layout.addWidget(self.time_label)
|