pyqt-todolist/view/MyDayView.py
2022-04-07 21:11:37 +08:00

31 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)