78 lines
2.4 KiB
Python
78 lines
2.4 KiB
Python
import os
|
|
import sys
|
|
|
|
from PyQt5.QtGui import *
|
|
from PyQt5.QtWidgets import *
|
|
from PyQt5.QtCore import Qt
|
|
|
|
from utils.QSSLoader import QSSLoader
|
|
from view.UserLabel import User
|
|
from view.SelfListWidgetItem import SelfListWidgetItem
|
|
|
|
|
|
class MainWidget(QWidget):
|
|
def __init__(self):
|
|
super(MainWidget, self).__init__()
|
|
self.user_label = User()
|
|
# 主布局,左右两侧
|
|
layout = QHBoxLayout()
|
|
# 子布局,左边的部分
|
|
self.sub_layout = QVBoxLayout()
|
|
self.sub_layout.spacing()
|
|
self.sub_layout.addWidget(self.user_label, 1)
|
|
# 左侧列表
|
|
self.system_listWidget = QListWidget(self)
|
|
self.sub_layout.addWidget(self.system_listWidget, 2)
|
|
|
|
# 可自定义添加的listWidget
|
|
self.self_listWidget = QListWidget(self)
|
|
self.sub_layout.addWidget(self.self_listWidget, 7)
|
|
# 右侧层叠窗口
|
|
self.stackedWidget = QStackedWidget(self)
|
|
|
|
layout.addLayout(self.sub_layout, Qt.AlignJustify)
|
|
|
|
layout.addWidget(self.stackedWidget, 2)
|
|
|
|
self.one_day = SelfListWidgetItem('我的一天', 1, os.getcwd() + '/../images/sun.svg')
|
|
self.self_listWidget.setCurrentRow(1)
|
|
# self.one_day.setSelected(True)
|
|
self.important = SelfListWidgetItem('重要', 0, os.getcwd() + '/../images/star.svg')
|
|
|
|
self.setLayout(layout)
|
|
self.initUI()
|
|
|
|
def initUI(self):
|
|
self.system_listWidget.addItem(self.one_day)
|
|
self.system_listWidget.setItemWidget(self.one_day, self.one_day.widget)
|
|
|
|
self.system_listWidget.addItem(self.important)
|
|
|
|
self.system_listWidget.setItemWidget(self.important, self.important.widget)
|
|
|
|
pass
|
|
|
|
|
|
class MainWindow(QWidget):
|
|
def __init__(self):
|
|
super(MainWindow, self).__init__()
|
|
self.resize(1050, 800)
|
|
self.setWindowTitle("待办事项")
|
|
# 主布局,用来显示主页面,设置页面等
|
|
self.layout = QStackedLayout(self)
|
|
|
|
self.main_widget = MainWidget()
|
|
# self.main_widget.resize(50, 200)
|
|
self.layout.addWidget(self.main_widget)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = QApplication(sys.argv)
|
|
main = MainWindow()
|
|
# print(os.path.abspath('../'))
|
|
style_sheet = QSSLoader.read_qss_file('../resource/current.qss')
|
|
main.setStyleSheet(style_sheet)
|
|
|
|
app.setWindowIcon(QIcon(os.path.abspath('../') + '/images/todo.svg'))
|
|
main.show()
|
|
sys.exit(app.exec_())
|