2022-04-01 22:25:19 +08:00
|
|
|
|
from PyQt5.QtWidgets import *
|
|
|
|
|
from PyQt5.QtGui import *
|
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SelfListWidgetItem(QListWidgetItem):
|
|
|
|
|
"""
|
|
|
|
|
:param item_name: 列表名称
|
2022-04-20 22:48:23 +08:00
|
|
|
|
:param uid: 当前列表的uuid
|
2022-04-01 22:25:19 +08:00
|
|
|
|
:param todo_count: 设置剩余代办数量,默认为零
|
|
|
|
|
:param show_icon: 设置显示的图标路径,默认为空
|
|
|
|
|
"""
|
|
|
|
|
|
2022-04-20 22:48:23 +08:00
|
|
|
|
def __init__(self, item_name, todo_count=0, uid=None, show_icon=None):
|
2022-04-01 22:25:19 +08:00
|
|
|
|
super(SelfListWidgetItem, self).__init__()
|
|
|
|
|
layout = QHBoxLayout()
|
|
|
|
|
# print(show_icon)
|
|
|
|
|
self.item_name = item_name
|
|
|
|
|
|
|
|
|
|
self.todo_count = todo_count
|
|
|
|
|
self.show_icon = show_icon
|
|
|
|
|
# 布局
|
|
|
|
|
self.widget = QWidget()
|
|
|
|
|
self.widget.setLayout(layout)
|
|
|
|
|
|
|
|
|
|
# self.list_item = QLabel('')
|
|
|
|
|
|
|
|
|
|
# 添加左边的图标和右边的气泡
|
|
|
|
|
if self.show_icon:
|
|
|
|
|
self.icon_label = QLabel('')
|
|
|
|
|
self.icon_label.setPixmap(
|
|
|
|
|
QPixmap(self.show_icon).scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
|
|
|
|
|
layout.addWidget(self.icon_label, 1)
|
|
|
|
|
# 添加
|
|
|
|
|
self.item_name_label = QLabel(self.item_name)
|
|
|
|
|
# print(self.item_name)
|
|
|
|
|
self.item_name_label.setObjectName('item_name_label')
|
2022-04-13 21:42:41 +08:00
|
|
|
|
|
2022-04-01 22:25:19 +08:00
|
|
|
|
layout.addWidget(self.item_name_label, 3)
|
|
|
|
|
|
|
|
|
|
if self.todo_count:
|
2022-04-04 22:34:07 +08:00
|
|
|
|
# 打印出代办数目
|
|
|
|
|
print('todo_count:', self.todo_count)
|
2022-04-01 22:25:19 +08:00
|
|
|
|
self.todo_count_label = QLabel(str(self.todo_count))
|
2022-04-04 22:34:07 +08:00
|
|
|
|
self.todo_count_label.setFixedSize(16, 16)
|
2022-04-01 22:25:19 +08:00
|
|
|
|
self.todo_count_label.setScaledContents(True)
|
|
|
|
|
self.todo_count_label.setObjectName('todo_count_label')
|
|
|
|
|
self.todo_count_label.setAlignment(Qt.AlignCenter)
|
|
|
|
|
layout.addWidget(self.todo_count_label, 1)
|
|
|
|
|
# 设置自定义的QListWidgetItem的sizeHint,不然无法显示
|
|
|
|
|
self.setSizeHint(self.widget.sizeHint())
|
2022-04-22 22:09:38 +08:00
|
|
|
|
# main=MainWidget()
|
|
|
|
|
|
|
|
|
|
def change_name(self):
|
|
|
|
|
pass
|