修改部分布局

This commit is contained in:
liyp 2022-04-07 21:11:37 +08:00
parent ff13cd521c
commit e009539a03
3 changed files with 46 additions and 3 deletions

View file

@ -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)

8
test/TimeTest.py Normal file
View file

@ -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])

31
view/MyDayView.py Normal file
View file

@ -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)