diff --git a/main/main.py b/main/main.py index 7df5557..d587674 100644 --- a/main/main.py +++ b/main/main.py @@ -7,6 +7,7 @@ from utils.QSSLoader import QSSLoader from view.UserLabel import User from view.SelfListWidgetItem import SelfListWidgetItem from view.AddListLabel import AddListAction +from view.MyDayView import MyDay class MainWidget(QWidget): @@ -27,7 +28,7 @@ class MainWidget(QWidget): # self.custom = QListWidget(self) # self.sub_layout.addWidget(self.custom, 7) - # todo : 需要把下面的重写QLabel解决问题,单个QLabel无法解决问题 + # 添加最下边的QLabel self.add_list_action = AddListAction() # self.add_item_label.setPixmap(QPixmap()) @@ -40,11 +41,14 @@ class MainWidget(QWidget): # self.custom.customContextMenuRequested.connect(self.myListWidgetContext) # 右侧层叠窗口 + + my_day=MyDay() self.stackedWidget = QStackedWidget(self) + self.stackedWidget.addWidget(my_day) - layout.addLayout(self.sub_layout, Qt.AlignJustify) + layout.addLayout(self.sub_layout, 2) - layout.addWidget(self.stackedWidget, 2) + layout.addWidget(self.stackedWidget, 6) self.one_day = SelfListWidgetItem('我的一天', 1, os.getcwd() + '/../images/sun.svg') self.system_listWidget.setCurrentRow(1) diff --git a/test/TimeTest.py b/test/TimeTest.py new file mode 100644 index 0000000..ebd5687 --- /dev/null +++ b/test/TimeTest.py @@ -0,0 +1,8 @@ +import datetime +import time + +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]) diff --git a/view/MyDayView.py b/view/MyDayView.py new file mode 100644 index 0000000..899f1d6 --- /dev/null +++ b/view/MyDayView.py @@ -0,0 +1,31 @@ +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)