from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtGui import QPixmap, QIcon from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt from utils.BasicUtils import change_value class ToDoItem(QListWidgetItem): transaction = pyqtSignal() """ :param todo_name : 新建的待办事项名称 :param uid : 待办事项的uid """ # todo : 参数添加uid,方便设置重要和我的一天 def __init__(self, todo_name, uid=None): super(ToDoItem, self).__init__() # print(' 添加的新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) self.mark_icon.clicked.connect(self.set_done) print(uid) self.important_button.clicked.connect(lambda: self.set_important(uid)) def set_done(self): pass def set_myday(self, uid): change_value(uid, 'done', True) pass def set_important(self, uid): # important = Important() # important.load_important.emit() # self.action.emit() change_value(uid, 'isImportant', True) self.transaction.emit() pass