40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
from PyQt5.QtWidgets import QLabel, QLineEdit, QHBoxLayout
|
|
from PyQt5.QtGui import QPixmap
|
|
from PyQt5.QtCore import Qt, pyqtSignal
|
|
|
|
|
|
class AddToDoAction(QLabel):
|
|
# 发送创建的ToDo名字
|
|
todo_name = pyqtSignal(str)
|
|
|
|
def __init__(self):
|
|
super(AddToDoAction, self).__init__()
|
|
self.setObjectName('add_todo_label')
|
|
# widget = QWidget(self)
|
|
self.setMinimumWidth(700)
|
|
layout = QHBoxLayout()
|
|
# widget.setLayout(layout)
|
|
icon = QPixmap('../images/add.png').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
|
|
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')
|
|
self.line_edit.setPlaceholderText('添加任务')
|
|
# 回车事件
|
|
# self.line_edit.returnPressed.connect(lambda: self.line_edit_add(self.line_edit.text()))
|
|
|
|
layout.addWidget(self.icon_label, 1, Qt.AlignLeft)
|
|
layout.addWidget(self.line_edit, 6, Qt.AlignLeft)
|
|
layout.addStretch(1)
|
|
|
|
self.setScaledContents(True)
|
|
|
|
# self.sizeHint()
|
|
self.setLayout(layout)
|
|
self.show()
|
|
|