修复几个bug

This commit is contained in:
liyp 2022-04-14 21:22:47 +08:00
parent 42bfede368
commit 8589fbabae
7 changed files with 121 additions and 40 deletions

View file

@ -1,12 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 44.1 (41455) - http://www.bohemiancoding.com/sketch -->
<title>Circle</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-2-Copy" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="55" stroke="#979797" fill-rule="nonzero" fill="#95909E">
<path d="M32,16 C32,24.836556 24.836556,32 16,32 C7.163444,32 0,24.836556 0,16 C0,7.163444 7.163444,0 16,0 C24.836556,0 32,7.163444 32,16 Z M2,16 C2,23.7319865 8.2680135,30 16,30 C23.7319865,30 30,23.7319865 30,16 C30,8.2680135 23.7319865,2 16,2 C8.2680135,2 2,8.2680135 2,16 Z" id="Oval-32" stroke="none"></path>
</g>
</g>
</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="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>

Before

Width:  |  Height:  |  Size: 879 B

After

Width:  |  Height:  |  Size: 720 B

View file

@ -40,11 +40,33 @@ QListWidget::item {
#todo_list{
min-width:700px;
min-height:650px;
border-top-left-radius:3px;
border-top-right-radius:3px;
border-bottom-left-radius:3px;
border-bottom-right-radius:3px;
background-color: rgba(211, 211, 211, 0.5);
}
#add_todo_label{
QLabel#add_todo_label{
width:500px;
max-height:60px;
border-top-left-radius:3px;
border-top-right-radius:3px;
border-bottom-left-radius:3px;
border-bottom-right-radius:3px;
background-color: rgba(211, 211, 211, 0.5);
}
QLineEdit#add_line_edit {
border: none;
background:transparent;
/* border-top-left-radius:3px;*/
/* border-top-right-radius:3px;*/
/* border-bottom-left-radius:3px;*/
/* border-bottom-right-radius:3px;*/
min-width:700px;
/* height:60px;*/
}
/*QPushButton {*/
/* max-width: 120px;*/
@ -156,14 +178,7 @@ QLabel#head_label{
/* border-radius: 10px;*/
/* padding-top:40px;}*/
/*QLineEdit {*/
/* border: 2px solid rgb(52,52,52);*/
/* border-top-left-radius:10px; */
/* border-top-right-radius:10px;*/
/* border-bottom-left-radius:10px;*/
/* border-bottom-right-radius:10px;*/
/*}*/
/*隐藏按钮右侧的下拉三角*/
QPushButton::menu-indicator{ image:none;}

View file

@ -1,27 +1,54 @@
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import Qt
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)
# widget.setMinimumWidth(500)
self.setMinimumWidth(700)
layout = QHBoxLayout()
# widget.setLayout(layout)
icon = QLabel()
icon.setPixmap(QPixmap('../images/circle.svg').scaled(50,50))
icon = QPixmap('../images/circle.svg').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()))
# self.line_edit.se
# self.line_edit.setEnabled(False)
# self.line_edit.
# todo : QLineEdit点击事件
# self.line_edit.setAlignment(Qt.AlignLeft)
layout.addWidget(icon, 1, Qt.AlignLeft)
layout.addWidget(self.line_edit,6,Qt.AlignCenter)
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()
# 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()

24
view/LineEdit.py Normal file
View file

@ -0,0 +1,24 @@
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import *
class LineEdit(QLineEdit):
clicked = pyqtSignal()
def __init__(self):
super(LineEdit, self).__init__()
# layout = QHBoxLayout()
# self.setLayout(layout)
# icon = QPixmap('../images/circle.svg').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
# icon_label = QLabel()
# icon_label.setPixmap(icon)
# icon_label.setMaximumSize(30, 30)
# icon_label.setScaledContents(True)
# layout.addWidget(icon_label)
def mousePressEvent(self, QMouseEvent):
# print('click left button')
if QMouseEvent.button() == Qt.LeftButton:
# self.setEnabled(False)
self.clicked.emit()

View file

@ -1,12 +1,10 @@
import os
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from view.AddToDoLabel import AddToDoAction
from view.MyDayHeadLabel import HeadLabel
from view.ChangeThemeLabel import ChangeTheme
class MyDay(QWidget):
@ -39,8 +37,10 @@ class MyDay(QWidget):
self.todo_list = QListWidget()
self.todo_list.setObjectName('todo_list')
# 添加ToDo的标签
self.add_todo = AddToDoAction()
self.add_todo.setAlignment(Qt.AlignBottom)
self.add_todo.setAlignment(Qt.AlignCenter)
self.add_todo.todo_name.connect(self.add_todo_action)
# head_widget.setPalette(palette)
@ -61,8 +61,7 @@ class MyDay(QWidget):
# self.menu_image.setScaledContents(True)
pic_btn = QPixmap(os.getcwd() + "/../images/menu.png")
self.menu_image.setIcon(QIcon(pic_btn))
# self.menu_image.setFixedSize(QPixmap(os.getcwd() + "/../images/menu.png").size())
# head_layout.addLayout(head_left_layout)
head_layout.addWidget(self.menu_image, 2)
head_layout.addStretch(1)
@ -83,7 +82,7 @@ class MyDay(QWidget):
theme_label.setDisabled(True)
button_menu.addAction(theme_label)
button_menu.addSeparator()
# button_menu
for i in range(11):
label_action = QAction(self)
label_action.setIcon(QIcon('../images/' + str(i) + '.jpg'))
@ -97,15 +96,15 @@ class MyDay(QWidget):
def menu_action(self, count):
# 点击按钮
# self.menu_label = ChangeTheme()
self.setStyleSheet('#my_day{background-image:url("../images/3.jpg");'
'background-position: center; border-radius: 10px;'
' padding-top:170px;}')
'}')
self.head_label.show()
print('选中:' + count)
# self.palette = QPalette()
# self.palette.setBrush(self.palette.Background, QBrush(QPixmap('../images/' + count + '.png')))
# self.setPalette(self.palette)
pass
def add_todo_action(self, name):
print(name)

View file

27
view/ToDoItem.py Normal file
View file

@ -0,0 +1,27 @@
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)