pyqt-todolist/view/ToDoItem.py

40 lines
1.4 KiB
Python
Raw Normal View History

2022-04-14 21:22:47 +08:00
from PyQt5.QtGui import QPixmap, QIcon
2022-04-30 10:00:43 +08:00
from PyQt5.QtWidgets import QListWidgetItem, QWidget, QHBoxLayout, QPushButton, QLabel
2022-04-14 21:22:47 +08:00
from PyQt5.QtCore import Qt
2022-04-21 22:42:43 +08:00
from utils.BasicUtils import change_value
2022-04-14 21:22:47 +08:00
class ToDoItem(QListWidgetItem):
2022-04-15 21:33:24 +08:00
"""
:param todo_name : 新建的待办事项名称
2022-04-21 22:42:43 +08:00
:param uid : 待办事项的uid
2022-04-15 21:33:24 +08:00
"""
2022-04-21 22:42:43 +08:00
def __init__(self, todo_name, uid=None):
2022-04-14 21:22:47 +08:00
super(ToDoItem, self).__init__()
2022-04-21 22:42:43 +08:00
# print('<ToDoItem> 添加的新ToDo' + todo_name)
2022-04-14 21:22:47 +08:00
2022-04-15 21:33:24 +08:00
self.widget = QWidget()
2022-04-14 21:22:47 +08:00
layout = QHBoxLayout()
2022-04-15 21:33:24 +08:00
# self.widget.setMinimumHeight(100)
self.widget.setLayout(layout)
self.widget.show()
2022-04-14 21:22:47 +08:00
self.mark_icon = QPushButton()
2022-04-15 21:33:24 +08:00
self.mark_icon.setObjectName('todo_mark_icon')
2022-04-14 21:22:47 +08:00
self.mark_icon.setIcon(
2022-04-15 21:33:24 +08:00
QIcon(QPixmap('../images/circle.svg').scaled(200, 200, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
2022-04-14 21:22:47 +08:00
self.todo_label = QLabel()
2022-04-15 21:33:24 +08:00
self.todo_label.setAlignment(Qt.AlignCenter)
if todo_name:
2022-04-14 21:22:47 +08:00
self.todo_label.setText(str(todo_name))
self.important_button = QPushButton()
2022-04-15 21:33:24 +08:00
self.important_button.setIcon(
2022-04-14 21:22:47 +08:00
QIcon(QPixmap('../images/star_list.svg').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
2022-04-15 21:33:24 +08:00
self.important_button.setObjectName('mark_important')
2022-04-14 21:22:47 +08:00
layout.addWidget(self.mark_icon, 2)
layout.addWidget(self.todo_label, 6)
2022-04-15 21:33:24 +08:00
layout.addWidget(self.important_button, 2)
2022-04-21 22:42:43 +08:00