添加ToDo功能实现
This commit is contained in:
parent
8589fbabae
commit
3aed356b27
10 changed files with 88 additions and 147 deletions
|
@ -1,3 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="新前缀"/>
|
||||
</RCC>
|
|
@ -1 +1 @@
|
|||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1649937952680" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3075" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M512 950.857143c242.358857 0 438.857143-196.498286 438.857143-438.857143S754.358857 73.142857 512 73.142857 73.142857 269.641143 73.142857 512s196.498286 438.857143 438.857143 438.857143z m0 73.142857C229.229714 1024 0 794.770286 0 512S229.229714 0 512 0s512 229.229714 512 512-229.229714 512-512 512z" p-id="3076" fill="#ffffff"></path></svg>
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1650028643069" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7202" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M512 903.110656c216.004608 0 391.110656-175.106048 391.110656-391.110656S728.004608 120.889344 512 120.889344 120.889344 295.995392 120.889344 512 295.995392 903.110656 512 903.110656z m0 64C260.64896 967.110656 56.889344 763.35104 56.889344 512S260.64896 56.889344 512 56.889344 967.110656 260.64896 967.110656 512 763.35104 967.110656 512 967.110656z" fill="#323233" p-id="7203"></path></svg>
|
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 771 B |
1
images/finish.svg
Normal file
1
images/finish.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1650028497138" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6378" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M405.36064 699.96544l-153.088-153.088a30.72 30.72 0 0 0-43.43808 43.43808l173.7728 173.7728a31.31392 31.31392 0 0 0 1.024 1.024 30.72 30.72 0 0 0 43.45856 0l376.50432-376.50432a30.72 30.72 0 0 0-43.43808-43.43808L405.36064 699.96544zM512 1024C229.23264 1024 0 794.76736 0 512S229.23264 0 512 0s512 229.23264 512 512-229.23264 512-512 512z" fill="#1F81D2" p-id="6379"></path></svg>
|
After Width: | Height: | Size: 757 B |
|
@ -37,8 +37,9 @@ QListWidget::item {
|
|||
font-family: black ;
|
||||
/* border-right: 4px solid rgb(9, 187, 7);*/
|
||||
}
|
||||
/*-------begin-------*/
|
||||
|
||||
#todo_list{
|
||||
QListWidget#todo_list{
|
||||
min-width:700px;
|
||||
min-height:650px;
|
||||
border-top-left-radius:3px;
|
||||
|
@ -47,6 +48,49 @@ QListWidget::item {
|
|||
border-bottom-right-radius:3px;
|
||||
background-color: rgba(211, 211, 211, 0.5);
|
||||
}
|
||||
/*添加Item的样式*/
|
||||
QListWidget#todo_list::item{
|
||||
min-height:60px;
|
||||
}
|
||||
|
||||
/*被选中时的背景颜色和左边框颜色*/
|
||||
|
||||
QListWidget#todo_list::item:hover {
|
||||
background: #eaeaea;
|
||||
}
|
||||
QListWidget#todo_list::item:selected {
|
||||
background: #ffffff;
|
||||
}
|
||||
/*#todo_mark_icon{*/
|
||||
/* max-width:30px;*/
|
||||
/* border-radius:5px;*/
|
||||
/*}*/
|
||||
|
||||
QPushButton#todo_mark_icon,#mark_important {
|
||||
/* padding: 3px 20px;*/
|
||||
/* text-align:center;*/
|
||||
background-color:#f3f3f3;
|
||||
border-radius:15px;
|
||||
min-width:40px;
|
||||
max-width:40px;
|
||||
min-height:40px;
|
||||
/* max-width:50px;*/
|
||||
/* min-height:50px;*/
|
||||
}
|
||||
/*QPushButton#todo_mark_icon:hover {*/
|
||||
/* padding: 3px 20px;*/
|
||||
/* text-align:center;*/
|
||||
/* background-color:#dddddd;*/
|
||||
/* border-radius:15px;*/
|
||||
/*}*/
|
||||
QPushButton#todo_mark_icon:pressed,#mark_important:pressed {
|
||||
/* padding: 3px 20px;*/
|
||||
/* text-align:center;*/
|
||||
background-color:#9f9f9f;
|
||||
border-radius:15px;
|
||||
}
|
||||
|
||||
/*------end------*/
|
||||
|
||||
QLabel#add_todo_label{
|
||||
width:500px;
|
||||
|
@ -65,7 +109,6 @@ QLineEdit#add_line_edit {
|
|||
/* border-bottom-left-radius:3px;*/
|
||||
/* border-bottom-right-radius:3px;*/
|
||||
min-width:700px;
|
||||
/* height:60px;*/
|
||||
|
||||
}
|
||||
/*QPushButton {*/
|
||||
|
|
|
@ -14,7 +14,7 @@ class AddToDoAction(QLabel):
|
|||
self.setMinimumWidth(700)
|
||||
layout = QHBoxLayout()
|
||||
# widget.setLayout(layout)
|
||||
icon = QPixmap('../images/circle.svg').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
|
||||
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)
|
||||
|
@ -25,12 +25,8 @@ class AddToDoAction(QLabel):
|
|||
# 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()))
|
||||
# self.line_edit.se
|
||||
# self.line_edit.setEnabled(False)
|
||||
# self.line_edit.
|
||||
# todo : QLineEdit点击事件
|
||||
# self.line_edit.setAlignment(Qt.AlignLeft)
|
||||
# 回车事件
|
||||
# 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)
|
||||
|
@ -45,10 +41,8 @@ class AddToDoAction(QLabel):
|
|||
# def line_edit_action(self):
|
||||
# print('click left button')
|
||||
|
||||
# todo : 回车添加事件
|
||||
def line_edit_add(self, name):
|
||||
self.todo_name.emit(name)
|
||||
print(name)
|
||||
self.line_edit.clear()
|
||||
|
||||
# widget.show()
|
||||
# # 回车添加事件
|
||||
# def line_edit_add(self, name):
|
||||
# self.todo_name.emit(name)
|
||||
# print(name)
|
||||
# self.line_edit.clear()
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'HeadDemo.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.15.6
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
Form.setObjectName("Form")
|
||||
Form.resize(400, 300)
|
||||
self.widget = QtWidgets.QWidget(Form)
|
||||
self.widget.setGeometry(QtCore.QRect(40, 90, 276, 90))
|
||||
self.widget.setObjectName("widget")
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
|
||||
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||
self.label = QtWidgets.QLabel(self.widget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(32)
|
||||
self.label.setFont(font)
|
||||
self.label.setObjectName("label")
|
||||
self.verticalLayout_2.addWidget(self.label)
|
||||
self.label_2 = QtWidgets.QLabel(self.widget)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.verticalLayout_2.addWidget(self.label_2)
|
||||
self.horizontalLayout.addLayout(self.verticalLayout_2)
|
||||
self.pushButton = QtWidgets.QPushButton(self.widget)
|
||||
self.pushButton.setStyleSheet("")
|
||||
self.pushButton.setObjectName("pushButton")
|
||||
self.horizontalLayout.addWidget(self.pushButton)
|
||||
|
||||
self.retranslateUi(Form)
|
||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Form.setWindowTitle(_translate("Form", "Form"))
|
||||
self.label.setText(_translate("Form", "我的一天"))
|
||||
self.label_2.setText(_translate("Form", "2022-04-12"))
|
||||
self.pushButton.setText(_translate("Form", "PushButton"))
|
|
@ -1,64 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>90</y>
|
||||
<width>276</width>
|
||||
<height>90</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>32</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>我的一天</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>2022-04-12</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -5,6 +5,7 @@ from PyQt5.QtCore import Qt
|
|||
|
||||
from view.AddToDoLabel import AddToDoAction
|
||||
from view.MyDayHeadLabel import HeadLabel
|
||||
from view.ToDoItem import ToDoItem
|
||||
|
||||
|
||||
class MyDay(QWidget):
|
||||
|
@ -35,12 +36,14 @@ class MyDay(QWidget):
|
|||
|
||||
head_widget.setAttribute(Qt.WA_StyledBackground)
|
||||
self.todo_list = QListWidget()
|
||||
self.todo_list.setFrameShape(QListWidget.NoFrame)
|
||||
self.todo_list.setObjectName('todo_list')
|
||||
|
||||
# 添加ToDo的标签
|
||||
self.add_todo = AddToDoAction()
|
||||
self.add_todo.line_edit.returnPressed.connect(lambda: self.line_edit_add(self.add_todo.line_edit.text()))
|
||||
self.add_todo.setAlignment(Qt.AlignCenter)
|
||||
self.add_todo.todo_name.connect(self.add_todo_action)
|
||||
# self.add_todo.todo_name.connect(self.add_todo_action)
|
||||
|
||||
# head_widget.setPalette(palette)
|
||||
|
||||
|
@ -97,14 +100,23 @@ class MyDay(QWidget):
|
|||
def menu_action(self, count):
|
||||
# 点击按钮
|
||||
|
||||
self.setStyleSheet('#my_day{background-image:url("../images/3.jpg");'
|
||||
self.setStyleSheet('#my_day{background-image:url("../images/4.jpg");'
|
||||
'background-position: center; border-radius: 10px;'
|
||||
'}')
|
||||
self.head_label.show()
|
||||
|
||||
print('选中:' + count)
|
||||
|
||||
#
|
||||
# def add_todo_action(self, name):
|
||||
# print(name)
|
||||
# todo : 回车添加事件
|
||||
def line_edit_add(self, name):
|
||||
self.add_todo.todo_name.emit(name)
|
||||
# print('添加的新ToDo:' + name)
|
||||
todo_item = ToDoItem(name)
|
||||
|
||||
self.todo_list.addItem(todo_item)
|
||||
self.todo_list.setItemWidget(todo_item, todo_item.widget)
|
||||
|
||||
def add_todo_action(self, name):
|
||||
print(name)
|
||||
self.add_todo.line_edit.clear()
|
||||
|
|
|
@ -37,7 +37,6 @@ class SelfListWidgetItem(QListWidgetItem):
|
|||
# print(self.item_name)
|
||||
self.item_name_label.setObjectName('item_name_label')
|
||||
|
||||
|
||||
layout.addWidget(self.item_name_label, 3)
|
||||
|
||||
if self.todo_count:
|
||||
|
@ -51,4 +50,3 @@ class SelfListWidgetItem(QListWidgetItem):
|
|||
layout.addWidget(self.todo_count_label, 1)
|
||||
# 设置自定义的QListWidgetItem的sizeHint,不然无法显示
|
||||
self.setSizeHint(self.widget.sizeHint())
|
||||
|
||||
|
|
|
@ -5,23 +5,32 @@ from PyQt5.QtCore import Qt
|
|||
|
||||
|
||||
class ToDoItem(QListWidgetItem):
|
||||
"""
|
||||
:param todo_name : 新建的待办事项名称
|
||||
"""
|
||||
|
||||
def __init__(self, todo_name):
|
||||
super(ToDoItem, self).__init__()
|
||||
print('添加的新ToDo:' + todo_name)
|
||||
|
||||
widget = QWidget(self)
|
||||
self.widget = QWidget()
|
||||
layout = QHBoxLayout()
|
||||
widget.setLayout(layout)
|
||||
widget.show()
|
||||
|
||||
# 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(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
|
||||
QIcon(QPixmap('../images/circle.svg').scaled(200, 200, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
|
||||
self.todo_label = QLabel()
|
||||
if not todo_name:
|
||||
self.todo_label.setAlignment(Qt.AlignCenter)
|
||||
if todo_name:
|
||||
self.todo_label.setText(str(todo_name))
|
||||
self.important_button = QPushButton()
|
||||
self.mark_icon.setIcon(
|
||||
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)
|
||||
layout.addWidget(self.important_button, 2)
|
||||
|
|
Loading…
Reference in a new issue