2022-04-30 10:00:43 +08:00
|
|
|
from PyQt5.QtWidgets import QLabel, QLineEdit, QHBoxLayout
|
2022-04-14 16:19:59 +08:00
|
|
|
from PyQt5.QtGui import QPixmap
|
2022-04-14 21:22:47 +08:00
|
|
|
from PyQt5.QtCore import Qt, pyqtSignal
|
2022-04-14 16:19:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
class AddToDoAction(QLabel):
|
2022-04-14 21:22:47 +08:00
|
|
|
# 发送创建的ToDo名字
|
|
|
|
todo_name = pyqtSignal(str)
|
|
|
|
|
2022-04-14 16:19:59 +08:00
|
|
|
def __init__(self):
|
|
|
|
super(AddToDoAction, self).__init__()
|
|
|
|
self.setObjectName('add_todo_label')
|
|
|
|
# widget = QWidget(self)
|
2022-04-14 21:22:47 +08:00
|
|
|
self.setMinimumWidth(700)
|
2022-04-14 16:19:59 +08:00
|
|
|
layout = QHBoxLayout()
|
|
|
|
# widget.setLayout(layout)
|
2022-04-15 21:33:24 +08:00
|
|
|
icon = QPixmap('../images/add.png').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
|
2022-04-14 21:22:47 +08:00
|
|
|
self.icon_label = QLabel()
|
|
|
|
self.icon_label.setPixmap(icon)
|
|
|
|
self.icon_label.setMaximumSize(30, 30)
|
|
|
|
self.icon_label.setScaledContents(True)
|
|
|
|
# icon_label.resize(icon.width(), icon.height())
|
|
|
|
self.line_edit = QLineEdit()
|
|
|
|
# self.line_edit.setMinimumHeight(50)
|
|
|
|
# self.line_edit.clicked.connect(self.line_edit_action)
|
|
|
|
self.line_edit.setObjectName('add_line_edit')
|
2022-04-14 16:19:59 +08:00
|
|
|
self.line_edit.setPlaceholderText('添加任务')
|
2022-04-15 21:33:24 +08:00
|
|
|
# 回车事件
|
|
|
|
# self.line_edit.returnPressed.connect(lambda: self.line_edit_add(self.line_edit.text()))
|
2022-04-14 16:19:59 +08:00
|
|
|
|
2022-04-14 21:22:47 +08:00
|
|
|
layout.addWidget(self.icon_label, 1, Qt.AlignLeft)
|
|
|
|
layout.addWidget(self.line_edit, 6, Qt.AlignLeft)
|
|
|
|
layout.addStretch(1)
|
2022-04-14 16:19:59 +08:00
|
|
|
|
|
|
|
self.setScaledContents(True)
|
|
|
|
|
|
|
|
# self.sizeHint()
|
|
|
|
self.setLayout(layout)
|
2022-04-14 21:22:47 +08:00
|
|
|
self.show()
|
|
|
|
|