pyqt-todolist/view/ToDoItem.py
2022-04-30 10:00:43 +08:00

39 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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