pyqt-todolist/view/ToDoItem.py

28 lines
987 B
Python
Raw Normal View History

2022-04-14 21:22:47 +08:00
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QIcon
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
class ToDoItem(QListWidgetItem):
def __init__(self, todo_name):
super(ToDoItem, self).__init__()
widget = QWidget(self)
layout = QHBoxLayout()
widget.setLayout(layout)
widget.show()
self.mark_icon = QPushButton()
self.mark_icon.setIcon(
QIcon(QPixmap('../images/circle.svg').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
self.todo_label = QLabel()
if not todo_name:
self.todo_label.setText(str(todo_name))
self.important_button = QPushButton()
self.mark_icon.setIcon(
QIcon(QPixmap('../images/star_list.svg').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
layout.addWidget(self.mark_icon, 2)
layout.addWidget(self.todo_label, 6)
layout.addWidget(self.important_button,2)