最终提交

This commit is contained in:
liyp 2022-05-24 11:14:06 +08:00
parent 742ff7547e
commit 3291579ea6
27 changed files with 3 additions and 2181 deletions

0
TODO
View file

View file

@ -211,7 +211,7 @@ class MainWidget(QWidget):
remove_todo_list(self.load_list[index][1])
del self.load_list[index]
# print('result:', self.load_list)
print('<main>(delete_item)', self.stackedWidget.indexOf(self.stackedWidget.currentWidget()))
# print('<main>(delete_item)', self.stackedWidget.indexOf(self.stackedWidget.currentWidget()))
self.stackedWidget.removeWidget(self.stackedWidget.currentWidget())
self.system_listWidget.takeItem(self.system_listWidget.currentRow())

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
PyQt5~=5.15.6
webdav4~=0.9.5

View file

@ -1,77 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年1月20日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: CircleImage
@description: 圆形图片
"""
import os
try:
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPainter, QPainterPath
from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout, QApplication
except ImportError:
from PySide2.QtCore import Qt
from PySide2.QtGui import QPixmap, QPainter, QPainterPath
from PySide2.QtWidgets import QLabel, QWidget, QHBoxLayout, QApplication
class Label(QLabel):
def __init__(self, *args, antialiasing=True, **kwargs):
super(Label, self).__init__(*args, **kwargs)
self.Antialiasing = antialiasing
self.setMaximumSize(200, 200)
self.setMinimumSize(200, 200)
self.radius = 100
#####################核心实现#########################
self.target = QPixmap(self.size()) # 大小和控件一样
self.target.fill(Qt.transparent) # 填充背景为透明
p = QPixmap(os.path.abspath('../') + '/images/user.svg').scaled( # 加载图片并缩放和控件一样大
200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
painter = QPainter(self.target)
if self.Antialiasing:
# 抗锯齿
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
# painter.setPen(# 测试圆圈
# QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
path = QPainterPath()
path.addRoundedRect(
0, 0, self.width(), self.height(), self.radius, self.radius)
# **** 切割为圆形 ****#
painter.setClipPath(path)
# painter.drawPath(path) # 测试圆圈
painter.drawPixmap(0, 0, p)
self.setPixmap(self.target)
#####################核心实现#########################
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QHBoxLayout(self)
layout.addWidget(Label(self))
layout.addWidget(Label(self, antialiasing=False))
self.setStyleSheet("background: white;")
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -1 +0,0 @@
import configparser

View file

@ -1,77 +0,0 @@
/*左侧*/
#listWidget {
outline: 0px;
max-width: 165px;
background-color: rgb(240, 240, 240);
}
#listWidget::item {
min-height: 45px;
}
#listWidget::item:hover {
background-color: rgb(225, 230, 235);
}
#listWidget::item:selected {
color: black;
background-color: rgb(255, 255, 255);
}
/*右侧*/
#titleLabel1,#titleLabel2,#titleLabel3,#titleLabel4,#titleLabel5,#titleLabel6,#titleLabel7,#titleLabel8 {
min-width: 75px;
max-width: 75px;
}
#right1,#right2,#right3,#right4,#right5,#right6 {
margin-left: 25px;
color: rgb(128, 128, 128);
}
/*所有按钮*/
QPushButton {
max-width: 80px;
max-height: 24px;
min-height: 24px;
border-radius: 3px;
background-color: rgb(244, 244, 244);
border: 1px solid rgb(167, 167, 167);
}
QPushButton:hover {
background-color: rgb(190, 231, 253);
}
QPushButton:pressed {
background-color: rgb(244, 244, 244);
}
QComboBox {
max-width: 80px;
max-height: 20px;
min-height: 20px;
}
QComboBox {
border: 1px solid rgb(167, 167, 167);
border-radius: 3px;
}
#listWidgetUser {
min-width: 290px;
max-width: 290px;
max-height: 120px;
min-height: 120px;
border-radius: 2px;
border: 1px solid rgb(227, 236, 242);
background-color: rgb(244, 250, 253);
}
QScrollBar::vertical {
background: rgb(178, 178, 178);
border: -5px solid grey;
margin: 0px 0px 0px 0px;
width: 10px;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: white;
}

View file

@ -1,60 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年6月14日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: FadeInOut
@description:
"""
from PyQt5.QtCore import QPropertyAnimation
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(400, 400)
layout = QVBoxLayout(self)
layout.addWidget(QPushButton('退出', self, clicked=self.doClose))
# 窗口透明度动画类
self.animation = QPropertyAnimation(self, b'windowOpacity')
self.animation.setDuration(1000) # 持续时间1秒
# 执行淡入
self.doShow()
def doShow(self):
try:
# 尝试先取消动画完成后关闭窗口的信号
self.animation.finished.disconnect(self.close)
except:
pass
self.animation.stop()
# 透明度范围从0逐渐增加到1
self.animation.setStartValue(0)
self.animation.setEndValue(1)
self.animation.start()
def doClose(self):
self.animation.stop()
self.animation.finished.connect(self.close) # 动画完成则关闭窗口
# 透明度范围从1逐渐减少到0
self.animation.setStartValue(1)
self.animation.setEndValue(0)
self.animation.start()
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -1,113 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年5月29日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: LeftTabWidget
@description:
"""
from random import randint
try:
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QWidget, QListWidget, QStackedWidget, QHBoxLayout, \
QListWidgetItem, QLabel
except ImportError:
from PySide2.QtCore import Qt, QSize
from PySide2.QtGui import QIcon
from PySide2.QtWidgets import QApplication, QWidget, QListWidget, QStackedWidget, QHBoxLayout, \
QListWidgetItem, QLabel
class LeftTabWidget(QWidget):
def __init__(self, *args, **kwargs):
super(LeftTabWidget, self).__init__(*args, **kwargs)
self.resize(800, 600)
# 左右布局(左边一个QListWidget + 右边QStackedWidget)
layout = QHBoxLayout(self, spacing=0)
layout.setContentsMargins(0, 0, 0, 0)
# 左侧列表
self.listWidget = QListWidget(self)
layout.addWidget(self.listWidget)
# 右侧层叠窗口
self.stackedWidget = QStackedWidget(self)
layout.addWidget(self.stackedWidget)
self.initUi()
def initUi(self):
# 初始化界面
# 通过QListWidget的当前item变化来切换QStackedWidget中的序号
self.listWidget.currentRowChanged.connect(
self.stackedWidget.setCurrentIndex)
# 去掉边框
self.listWidget.setFrameShape(QListWidget.NoFrame)
# 隐藏滚动条
self.listWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.listWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
# 这里就用一般的文本配合图标模式了(也可以直接用Icon模式,setViewMode)
for i in range(20):
item = QListWidgetItem(
QIcon('Data/0%d.ico' % randint(1, 8)), str('选 项 %s' % i), self.listWidget)
# 设置item的默认宽高(这里只有高度比较有用)
item.setSizeHint(QSize(16777215, 60))
# 文字居中
item.setTextAlignment(Qt.AlignCenter)
# 再模拟20个右侧的页面(就不和上面一起循环放了)
for i in range(20):
label = QLabel('我是页面 %d' % i, self)
label.setAlignment(Qt.AlignCenter)
# 设置label的背景颜色(这里随机)
# 这里加了一个margin边距(方便区分QStackedWidget和QLabel的颜色)
label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % (
randint(0, 255), randint(0, 255), randint(0, 255)))
self.stackedWidget.addWidget(label)
# 美化样式表
Stylesheet = """
/*去掉item虚线边框*/
QListWidget, QListView, QTreeWidget, QTreeView {
outline: 0px;
}
/*设置左侧选项的最小最大宽度,文字颜色和背景颜色*/
QListWidget {
min-width: 120px;
max-width: 120px;
color: white;
background: black;
}
/*被选中时的背景颜色和左边框颜色*/
QListWidget::item:selected {
background: rgb(52, 52, 52);
border-left: 2px solid rgb(9, 187, 7);
}
/*鼠标悬停颜色*/
HistoryPanel::item:hover {
background: rgb(52, 52, 52);
}
/*右侧的层叠窗口的背景颜色*/
QStackedWidget {
background: rgb(30, 30, 30);
}
/*模拟的页面*/
QLabel {
color: white;
}
"""
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
app.setStyleSheet(Stylesheet)
w = LeftTabWidget()
w.show()
sys.exit(app.exec_())

View file

@ -1,501 +0,0 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'setting.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!
try:
from PyQt5 import QtCore, QtWidgets
except ImportError:
from PySide2 import QtCore, QtWidgets
class Ui_Setting(object):
def setupUi(self, Setting):
Setting.setObjectName("Setting")
Setting.resize(498, 498)
self.horizontalLayout = QtWidgets.QHBoxLayout(Setting)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.listWidget = QtWidgets.QListWidget(Setting)
self.listWidget.setFrameShape(QtWidgets.QFrame.NoFrame)
self.listWidget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.listWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.listWidget.setObjectName("listWidget")
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
self.horizontalLayout.addWidget(self.listWidget)
self.scrollArea = QtWidgets.QScrollArea(Setting)
self.scrollArea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -810, 460, 1308))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout.setContentsMargins(35, 20, 35, 20)
self.verticalLayout.setSpacing(20)
self.verticalLayout.setObjectName("verticalLayout")
self.widget_0 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_0.setObjectName("widget_0")
self.formLayout = QtWidgets.QFormLayout(self.widget_0)
self.formLayout.setContentsMargins(0, 0, 0, 0)
self.formLayout.setObjectName("formLayout")
self.titleLabel1 = QtWidgets.QLabel(self.widget_0)
self.titleLabel1.setObjectName("titleLabel1")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel1)
self.CheckBox = QtWidgets.QCheckBox(self.widget_0)
self.CheckBox.setObjectName("CheckBox")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.CheckBox)
self.checkBox = QtWidgets.QCheckBox(self.widget_0)
self.checkBox.setChecked(True)
self.checkBox.setObjectName("checkBox")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox)
self.checkBox_2 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_2.setChecked(True)
self.checkBox_2.setObjectName("checkBox_2")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_2)
self.checkBox_3 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_3.setObjectName("checkBox_3")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_3)
self.checkBox_4 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_4.setObjectName("checkBox_4")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_4)
self.checkBox_5 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_5.setObjectName("checkBox_5")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.checkBox_5)
self.checkBox_6 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_6.setObjectName("checkBox_6")
self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.checkBox_6)
self.verticalLayout.addWidget(self.widget_0)
self.widget_1 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_1.setObjectName("widget_1")
self.formLayout_8 = QtWidgets.QFormLayout(self.widget_1)
self.formLayout_8.setContentsMargins(0, 0, 0, 0)
self.formLayout_8.setObjectName("formLayout_8")
self.titleLabel2 = QtWidgets.QLabel(self.widget_1)
self.titleLabel2.setObjectName("titleLabel2")
self.formLayout_8.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel2)
self.checkBox_26 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_26.setObjectName("checkBox_26")
self.formLayout_8.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_26)
self.checkBox_27 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_27.setObjectName("checkBox_27")
self.formLayout_8.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_27)
self.checkBox_28 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_28.setObjectName("checkBox_28")
self.formLayout_8.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_28)
self.checkBox_29 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_29.setObjectName("checkBox_29")
self.formLayout_8.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_29)
self.label_10 = QtWidgets.QLabel(self.widget_1)
self.label_10.setObjectName("label_10")
self.formLayout_8.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.label_10)
self.right1 = QtWidgets.QRadioButton(self.widget_1)
self.right1.setObjectName("right1")
self.formLayout_8.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.right1)
self.right2 = QtWidgets.QRadioButton(self.widget_1)
self.right2.setChecked(True)
self.right2.setObjectName("right2")
self.formLayout_8.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.right2)
self.label_11 = QtWidgets.QLabel(self.widget_1)
self.label_11.setObjectName("label_11")
self.formLayout_8.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.label_11)
self.right3 = QtWidgets.QPushButton(self.widget_1)
self.right3.setObjectName("right3")
self.formLayout_8.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.right3)
self.verticalLayout.addWidget(self.widget_1)
self.widget_2 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_2.setObjectName("widget_2")
self.formLayout_9 = QtWidgets.QFormLayout(self.widget_2)
self.formLayout_9.setContentsMargins(0, 0, 0, 0)
self.formLayout_9.setObjectName("formLayout_9")
self.titleLabel3 = QtWidgets.QLabel(self.widget_2)
self.titleLabel3.setObjectName("titleLabel3")
self.formLayout_9.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel3)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label_13 = QtWidgets.QLabel(self.widget_2)
self.label_13.setObjectName("label_13")
self.horizontalLayout_2.addWidget(self.label_13)
self.comboBox = QtWidgets.QComboBox(self.widget_2)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.horizontalLayout_2.addWidget(self.comboBox)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.formLayout_9.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout_2)
self.checkBox_30 = QtWidgets.QCheckBox(self.widget_2)
self.checkBox_30.setObjectName("checkBox_30")
self.formLayout_9.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_30)
self.right4 = QtWidgets.QLabel(self.widget_2)
self.right4.setObjectName("right4")
self.formLayout_9.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.right4)
self.checkBox_31 = QtWidgets.QCheckBox(self.widget_2)
self.checkBox_31.setObjectName("checkBox_31")
self.formLayout_9.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_31)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.pushButton_5 = QtWidgets.QPushButton(self.widget_2)
self.pushButton_5.setObjectName("pushButton_5")
self.horizontalLayout_3.addWidget(self.pushButton_5)
self.pushButton_4 = QtWidgets.QPushButton(self.widget_2)
self.pushButton_4.setObjectName("pushButton_4")
self.horizontalLayout_3.addWidget(self.pushButton_4)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem1)
self.formLayout_9.setLayout(4, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout_3)
self.verticalLayout.addWidget(self.widget_2)
self.widget_3 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_3.setObjectName("widget_3")
self.formLayout_2 = QtWidgets.QFormLayout(self.widget_3)
self.formLayout_2.setContentsMargins(0, 0, 0, 0)
self.formLayout_2.setObjectName("formLayout_2")
self.titleLabel4 = QtWidgets.QLabel(self.widget_3)
self.titleLabel4.setObjectName("titleLabel4")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel4)
self.CheckBox_2 = QtWidgets.QCheckBox(self.widget_3)
self.CheckBox_2.setChecked(True)
self.CheckBox_2.setObjectName("CheckBox_2")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.CheckBox_2)
self.checkBox_7 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_7.setObjectName("checkBox_7")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_7)
self.checkBox_8 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_8.setObjectName("checkBox_8")
self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_8)
self.checkBox_9 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_9.setChecked(True)
self.checkBox_9.setObjectName("checkBox_9")
self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_9)
self.checkBox_10 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_10.setChecked(True)
self.checkBox_10.setObjectName("checkBox_10")
self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_10)
self.checkBox_11 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_11.setChecked(True)
self.checkBox_11.setObjectName("checkBox_11")
self.formLayout_2.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.checkBox_11)
self.checkBox_12 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_12.setChecked(True)
self.checkBox_12.setObjectName("checkBox_12")
self.formLayout_2.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.checkBox_12)
self.checkBox_13 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_13.setChecked(True)
self.checkBox_13.setObjectName("checkBox_13")
self.formLayout_2.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.checkBox_13)
self.checkBox_14 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_14.setChecked(True)
self.checkBox_14.setObjectName("checkBox_14")
self.formLayout_2.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.checkBox_14)
self.checkBox_15 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_15.setChecked(True)
self.checkBox_15.setObjectName("checkBox_15")
self.formLayout_2.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.checkBox_15)
self.verticalLayout.addWidget(self.widget_3)
self.widget_4 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_4.setObjectName("widget_4")
self.formLayout_3 = QtWidgets.QFormLayout(self.widget_4)
self.formLayout_3.setContentsMargins(0, 0, 0, 0)
self.formLayout_3.setObjectName("formLayout_3")
self.titleLabel5 = QtWidgets.QLabel(self.widget_4)
self.titleLabel5.setObjectName("titleLabel5")
self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel5)
self.checkBox_16 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_16.setChecked(True)
self.checkBox_16.setObjectName("checkBox_16")
self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_16)
self.checkBox_17 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_17.setChecked(True)
self.checkBox_17.setObjectName("checkBox_17")
self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_17)
self.checkBox_18 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_18.setChecked(True)
self.checkBox_18.setObjectName("checkBox_18")
self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_18)
self.checkBox_19 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_19.setChecked(True)
self.checkBox_19.setObjectName("checkBox_19")
self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_19)
self.verticalLayout.addWidget(self.widget_4)
self.widget_5 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_5.setObjectName("widget_5")
self.formLayout_4 = QtWidgets.QFormLayout(self.widget_5)
self.formLayout_4.setContentsMargins(0, 0, 0, 0)
self.formLayout_4.setObjectName("formLayout_4")
self.titleLabel6 = QtWidgets.QLabel(self.widget_5)
self.titleLabel6.setObjectName("titleLabel6")
self.formLayout_4.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel6)
self.checkBox_20 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_20.setObjectName("checkBox_20")
self.formLayout_4.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_20)
self.checkBox_21 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_21.setObjectName("checkBox_21")
self.formLayout_4.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_21)
self.checkBox_22 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_22.setObjectName("checkBox_22")
self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_22)
self.checkBox_23 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_23.setObjectName("checkBox_23")
self.formLayout_4.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_23)
self.checkBox_24 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_24.setObjectName("checkBox_24")
self.formLayout_4.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_24)
self.right5 = QtWidgets.QLabel(self.widget_5)
self.right5.setObjectName("right5")
self.formLayout_4.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.right5)
self.label_3 = QtWidgets.QLabel(self.widget_5)
self.label_3.setObjectName("label_3")
self.formLayout_4.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.label_3)
self.label_4 = QtWidgets.QLabel(self.widget_5)
self.label_4.setObjectName("label_4")
self.formLayout_4.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.label_4)
self.radioButton = QtWidgets.QRadioButton(self.widget_5)
self.radioButton.setObjectName("radioButton")
self.formLayout_4.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.radioButton)
self.radioButton_2 = QtWidgets.QRadioButton(self.widget_5)
self.radioButton_2.setObjectName("radioButton_2")
self.formLayout_4.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.radioButton_2)
self.radioButton_3 = QtWidgets.QRadioButton(self.widget_5)
self.radioButton_3.setChecked(True)
self.radioButton_3.setObjectName("radioButton_3")
self.formLayout_4.setWidget(10, QtWidgets.QFormLayout.FieldRole, self.radioButton_3)
self.formLayout_5 = QtWidgets.QFormLayout()
self.formLayout_5.setObjectName("formLayout_5")
self.listWidgetUser = QtWidgets.QListWidget(self.widget_5)
self.listWidgetUser.setFrameShape(QtWidgets.QFrame.NoFrame)
self.listWidgetUser.setObjectName("listWidgetUser")
self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.listWidgetUser)
self.pushButton = QtWidgets.QPushButton(self.widget_5)
self.pushButton.setObjectName("pushButton")
self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.pushButton)
self.formLayout_4.setLayout(11, QtWidgets.QFormLayout.FieldRole, self.formLayout_5)
self.verticalLayout.addWidget(self.widget_5)
self.widget_6 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_6.setObjectName("widget_6")
self.formLayout_6 = QtWidgets.QFormLayout(self.widget_6)
self.formLayout_6.setContentsMargins(0, 0, 0, 0)
self.formLayout_6.setObjectName("formLayout_6")
self.titleLabel7 = QtWidgets.QLabel(self.widget_6)
self.titleLabel7.setObjectName("titleLabel7")
self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel7)
self.label_6 = QtWidgets.QLabel(self.widget_6)
self.label_6.setObjectName("label_6")
self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.label_6)
self.pushButton_2 = QtWidgets.QPushButton(self.widget_6)
self.pushButton_2.setObjectName("pushButton_2")
self.formLayout_6.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.pushButton_2)
self.verticalLayout.addWidget(self.widget_6)
self.widget_7 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_7.setObjectName("widget_7")
self.formLayout_7 = QtWidgets.QFormLayout(self.widget_7)
self.formLayout_7.setContentsMargins(0, 0, 0, 0)
self.formLayout_7.setObjectName("formLayout_7")
self.titleLabel8 = QtWidgets.QLabel(self.widget_7)
self.titleLabel8.setObjectName("titleLabel8")
self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel8)
self.checkBox_25 = QtWidgets.QCheckBox(self.widget_7)
self.checkBox_25.setObjectName("checkBox_25")
self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_25)
self.right6 = QtWidgets.QLabel(self.widget_7)
self.right6.setObjectName("right6")
self.formLayout_7.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.right6)
self.verticalLayout.addWidget(self.widget_7)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.horizontalLayout.addWidget(self.scrollArea)
self.retranslateUi(Setting)
self.listWidget.setCurrentRow(0)
QtCore.QMetaObject.connectSlotsByName(Setting)
Setting.setTabOrder(self.listWidget, self.scrollArea)
Setting.setTabOrder(self.scrollArea, self.CheckBox)
Setting.setTabOrder(self.CheckBox, self.checkBox)
Setting.setTabOrder(self.checkBox, self.checkBox_2)
Setting.setTabOrder(self.checkBox_2, self.checkBox_3)
Setting.setTabOrder(self.checkBox_3, self.checkBox_4)
Setting.setTabOrder(self.checkBox_4, self.checkBox_5)
Setting.setTabOrder(self.checkBox_5, self.checkBox_6)
Setting.setTabOrder(self.checkBox_6, self.checkBox_26)
Setting.setTabOrder(self.checkBox_26, self.checkBox_27)
Setting.setTabOrder(self.checkBox_27, self.checkBox_28)
Setting.setTabOrder(self.checkBox_28, self.checkBox_29)
Setting.setTabOrder(self.checkBox_29, self.right1)
Setting.setTabOrder(self.right1, self.right2)
Setting.setTabOrder(self.right2, self.right3)
Setting.setTabOrder(self.right3, self.comboBox)
Setting.setTabOrder(self.comboBox, self.checkBox_30)
Setting.setTabOrder(self.checkBox_30, self.checkBox_31)
Setting.setTabOrder(self.checkBox_31, self.pushButton_5)
Setting.setTabOrder(self.pushButton_5, self.pushButton_4)
Setting.setTabOrder(self.pushButton_4, self.CheckBox_2)
Setting.setTabOrder(self.CheckBox_2, self.checkBox_7)
Setting.setTabOrder(self.checkBox_7, self.checkBox_8)
Setting.setTabOrder(self.checkBox_8, self.checkBox_9)
Setting.setTabOrder(self.checkBox_9, self.checkBox_10)
Setting.setTabOrder(self.checkBox_10, self.checkBox_11)
Setting.setTabOrder(self.checkBox_11, self.checkBox_12)
Setting.setTabOrder(self.checkBox_12, self.checkBox_13)
Setting.setTabOrder(self.checkBox_13, self.checkBox_14)
Setting.setTabOrder(self.checkBox_14, self.checkBox_15)
Setting.setTabOrder(self.checkBox_15, self.checkBox_16)
Setting.setTabOrder(self.checkBox_16, self.checkBox_17)
Setting.setTabOrder(self.checkBox_17, self.checkBox_18)
Setting.setTabOrder(self.checkBox_18, self.checkBox_19)
Setting.setTabOrder(self.checkBox_19, self.checkBox_20)
Setting.setTabOrder(self.checkBox_20, self.checkBox_21)
Setting.setTabOrder(self.checkBox_21, self.checkBox_22)
Setting.setTabOrder(self.checkBox_22, self.checkBox_23)
Setting.setTabOrder(self.checkBox_23, self.checkBox_24)
Setting.setTabOrder(self.checkBox_24, self.radioButton)
Setting.setTabOrder(self.radioButton, self.radioButton_2)
Setting.setTabOrder(self.radioButton_2, self.radioButton_3)
Setting.setTabOrder(self.radioButton_3, self.listWidgetUser)
Setting.setTabOrder(self.listWidgetUser, self.pushButton)
Setting.setTabOrder(self.pushButton, self.pushButton_2)
Setting.setTabOrder(self.pushButton_2, self.checkBox_25)
def retranslateUi(self, Setting):
_translate = QtCore.QCoreApplication.translate
Setting.setWindowTitle(_translate("Setting", "仿QQ设置面板"))
__sortingEnabled = self.listWidget.isSortingEnabled()
self.listWidget.setSortingEnabled(False)
item = self.listWidget.item(0)
item.setText(_translate("Setting", "登录"))
item = self.listWidget.item(1)
item.setText(_translate("Setting", "主面板"))
item = self.listWidget.item(2)
item.setText(_translate("Setting", "状态"))
item = self.listWidget.item(3)
item.setText(_translate("Setting", "会话窗口"))
item = self.listWidget.item(4)
item.setText(_translate("Setting", "信息展示"))
item = self.listWidget.item(5)
item.setText(_translate("Setting", "提醒"))
item = self.listWidget.item(6)
item.setText(_translate("Setting", "热键"))
item = self.listWidget.item(7)
item.setText(_translate("Setting", "显示"))
item = self.listWidget.item(8)
item.setText(_translate("Setting", "声音"))
item = self.listWidget.item(9)
item.setText(_translate("Setting", "软件更新"))
item = self.listWidget.item(10)
item.setText(_translate("Setting", "文件管理"))
item = self.listWidget.item(11)
item.setText(_translate("Setting", "文件共享"))
item = self.listWidget.item(12)
item.setText(_translate("Setting", "音视频通话"))
self.listWidget.setSortingEnabled(__sortingEnabled)
self.titleLabel1.setText(_translate("Setting", "登录:"))
self.CheckBox.setText(_translate("Setting", "开机时自动启动QQ"))
self.checkBox.setText(_translate("Setting", "启动QQ时为我自动登录"))
self.checkBox_2.setText(_translate("Setting", "总是打开登录提示"))
self.checkBox_3.setText(_translate("Setting", "离线自动启动QQ手机版仅支持Android"))
self.checkBox_4.setText(_translate("Setting", "登录后自动运行QQ宠物"))
self.checkBox_5.setText(_translate("Setting", "订阅“腾讯视频”,获取量身定制视频资讯"))
self.checkBox_6.setText(_translate("Setting", "订阅“每日精选”,了解最新商品资讯"))
self.titleLabel2.setText(_translate("Setting", "主面板:"))
self.checkBox_26.setText(_translate("Setting", "始终保持在其他窗口前端"))
self.checkBox_27.setText(_translate("Setting", "停靠在桌面边缘时自动隐藏"))
self.checkBox_28.setText(_translate("Setting", "在任务栏通知区域显示QQ图标"))
self.checkBox_29.setText(_translate("Setting", "显示天气"))
self.label_10.setText(_translate("Setting", "关闭主面板时:"))
self.right1.setText(_translate("Setting", "隐藏到任务栏通知区域,不退出程序"))
self.right2.setText(_translate("Setting", "退出程序"))
self.label_11.setText(_translate("Setting", "您可以自由定制适合您的面板和功能使用QQ更有效率"))
self.right3.setText(_translate("Setting", "界面管理器"))
self.titleLabel3.setText(_translate("Setting", "状态:"))
self.label_13.setText(_translate("Setting", "登陆后状态为:"))
self.comboBox.setItemText(0, _translate("Setting", "我在线上"))
self.comboBox.setItemText(1, _translate("Setting", "Q我吧"))
self.comboBox.setItemText(2, _translate("Setting", "离开"))
self.comboBox.setItemText(3, _translate("Setting", "忙碌"))
self.comboBox.setItemText(4, _translate("Setting", "请勿打扰"))
self.comboBox.setItemText(5, _translate("Setting", "隐身"))
self.checkBox_30.setText(_translate("Setting", "运行全屏程序时切换至“忙碌“状态””"))
self.right4.setText(_translate("Setting", "仅在“Q我吧”和“我在线上”状态下生效"))
self.checkBox_31.setText(_translate("Setting", "离开、忙碌、请勿打扰时自动回复100字以内"))
self.pushButton_5.setText(_translate("Setting", "自动回复设置"))
self.pushButton_4.setText(_translate("Setting", "快捷回复设置"))
self.titleLabel4.setText(_translate("Setting", "会话窗口:"))
self.CheckBox_2.setText(_translate("Setting", "使用多彩气泡聊天"))
self.checkBox_7.setText(_translate("Setting", "不显示广告(会员设置项)"))
self.checkBox_8.setText(_translate("Setting", "允许来消息时自动弹出窗口"))
self.checkBox_9.setText(_translate("Setting", "默认使用腾讯视频播放视频文件"))
self.checkBox_10.setText(_translate("Setting", "允许自动播放魔法表情和超级表情"))
self.checkBox_11.setText(_translate("Setting", "允许使用QQ秀聊天随动表情"))
self.checkBox_12.setText(_translate("Setting", "总是显示好友聊天窗口侧边栏"))
self.checkBox_13.setText(_translate("Setting", "允许接收窗口抖动"))
self.checkBox_14.setText(_translate("Setting", "显示热词搜索提示"))
self.checkBox_15.setText(_translate("Setting", "显示历史消息记录"))
self.titleLabel5.setText(_translate("Setting", "信息展示:"))
self.checkBox_16.setText(_translate("Setting", "在资料卡和迷你信息卡上显示等级图标"))
self.checkBox_17.setText(_translate("Setting", "在资料卡和迷你卡上显示更新搜索"))
self.checkBox_18.setText(_translate("Setting", "在聊天窗口内展示好友的更新摘要"))
self.checkBox_19.setText(_translate("Setting", "在聊天窗口内展示好友互动标识"))
self.titleLabel6.setText(_translate("Setting", "提醒:"))
self.checkBox_20.setText(_translate("Setting", "会话消息提醒"))
self.checkBox_21.setText(_translate("Setting", "新邮件提醒"))
self.checkBox_22.setText(_translate("Setting", "启用QQ看点消息"))
self.checkBox_23.setText(_translate("Setting", "启用一声问候消息"))
self.checkBox_24.setText(_translate("Setting", "启用设备连接提醒"))
self.right5.setText(_translate("Setting", "当插入安卓设备时提示安装或者更新QQ手机版"))
self.label_3.setText(_translate("Setting",
"<html><head/><body><p>您可以设置是否在屏幕右下角收到来自QQ空间的通知<a href=\"#\"><span style=\" text-decoration: none; color:#00aaff;\">进入设置</span></a>。</p></body></html>"))
self.label_4.setText(_translate("Setting", "好友上线提醒"))
self.radioButton.setText(_translate("Setting", "关闭好友上线提醒"))
self.radioButton_2.setText(_translate("Setting", "全部好友上线提醒"))
self.radioButton_3.setText(_translate("Setting", "以下好友上线提醒"))
self.pushButton.setText(_translate("Setting", "添加"))
self.titleLabel7.setText(_translate("Setting", "热键:"))
self.label_6.setText(_translate("Setting", "您可以通过点击选择要更改的热键"))
self.pushButton_2.setText(_translate("Setting", "设置热键"))
self.titleLabel8.setText(_translate("Setting", "显示:"))
self.checkBox_25.setText(_translate("Setting", "开启QQ适配屏幕DPI"))
self.right6.setText(_translate("Setting", "关闭选项后QQ将保持默认大小设置后需要重新登录才能生效"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Setting = QtWidgets.QWidget()
ui = Ui_Setting()
ui.setupUi(Setting)
Setting.show()
sys.exit(app.exec_())

View file

@ -1,63 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年8月22日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: MenuAnimation
@description:
"""
from PyQt5.QtCore import QPropertyAnimation, QEasingCurve, QRect
from PyQt5.QtWidgets import QWidget, QMenu, QApplication
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(800, 600)
self.initMenu()
self.initAnimation()
def contextMenuEvent(self, event):
pos = event.globalPos()
size = self._contextMenu.sizeHint()
x, y, w, h = pos.x(), pos.y(), size.width(), size.height()
self._animation.stop()
self._animation.setStartValue(QRect(x, y, 0, 0))
self._animation.setEndValue(QRect(x, y, w, h))
self._animation.start()
self._contextMenu.exec_(event.globalPos())
def hello(self):
QApplication.instance().aboutQt()
def initAnimation(self):
# 按钮动画
self._animation = QPropertyAnimation(
self._contextMenu, b'geometry', self,
easingCurve=QEasingCurve.Linear, duration=300)
# easingCurve 修改该变量可以实现不同的效果
def initMenu(self):
self._contextMenu = QMenu(self)
self._contextMenu.addAction('菜单1', self.hello)
self._contextMenu.addAction('菜单2', self.hello)
self._contextMenu.addAction('菜单3', self.hello)
self._contextMenu.addAction('菜单4', self.hello)
self._contextMenu.addAction('菜单5', self.hello)
self._contextMenu.addAction('菜单6', self.hello)
if __name__ == '__main__':
import sys
import cgitb
cgitb.enable(format='text')
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -1,96 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
try:
from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import (
QApplication, QMainWindow,
QLabel, QGridLayout, QWidget,
QCheckBox, QSystemTrayIcon,
QSpacerItem, QSizePolicy, QMenu, QAction, QStyle)
except ImportError:
from PySide2.QtCore import QSize
from PySide2.QtWidgets import (
QApplication, QMainWindow,
QLabel, QGridLayout, QWidget,
QCheckBox, QSystemTrayIcon,
QSpacerItem, QSizePolicy, QMenu, QAction, QStyle)
class MainWindow(QMainWindow):
"""
Сheckbox and system tray icons.
Will initialize in the constructor.
"""
check_box = None
tray_icon = None
# Override the class constructor
def __init__(self):
# Be sure to call the super class method
QMainWindow.__init__(self)
self.setMinimumSize(QSize(480, 80)) # Set sizes
self.setWindowTitle("System Tray Application") # Set a title
# Create a central widget
central_widget = QWidget(self)
# Set the central widget
self.setCentralWidget(central_widget)
grid_layout = QGridLayout(self) # Create a QGridLayout
# Set the layout into the central widget
central_widget.setLayout(grid_layout)
grid_layout.addWidget(
QLabel("Application, which can minimize to Tray", self), 0, 0)
# Add a checkbox, which will depend on the behavior of the program when the window is closed
self.check_box = QCheckBox('Minimize to Tray')
grid_layout.addWidget(self.check_box, 1, 0)
grid_layout.addItem(QSpacerItem(
0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding), 2, 0)
# Init QSystemTrayIcon
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setIcon(
self.style().standardIcon(QStyle.SP_ComputerIcon))
'''
Define and add steps to work with the system tray icon
show - show window
hide - hide window
exit - exit from application
'''
show_action = QAction("Show", self)
quit_action = QAction("Exit", self)
hide_action = QAction("Hide", self)
show_action.triggered.connect(self.show)
hide_action.triggered.connect(self.hide)
quit_action.triggered.connect(QApplication.instance().quit)
tray_menu = QMenu()
tray_menu.addAction(show_action)
tray_menu.addAction(hide_action)
tray_menu.addAction(quit_action)
self.tray_icon.setContextMenu(tray_menu)
self.tray_icon.show()
# Override closeEvent, to intercept the window closing event
# The window will be closed only if there is no check mark in the check box
def closeEvent(self, event):
if self.check_box.isChecked():
event.ignore()
self.hide()
self.tray_icon.showMessage(
"Tray Program",
"Application was minimized to Tray",
QSystemTrayIcon.Information,
2000
)
if __name__ == "__main__":
app = QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())

View file

@ -1,42 +0,0 @@
from PyQt5.QtWidgets import *
import sys
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
# 设置窗口标题和大小
self.setWindowTitle('TestWindow')
self.resize(400, 300)
self.collec_btn = QPushButton('打开新窗口', self)
layout = QVBoxLayout()
layout.addWidget(self.collec_btn)
self.setLayout(layout)
self.show()
class NewWindow(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('新窗口')
self.resize(280, 230)
if __name__ == '__main__':
app = QApplication(sys.argv)
# 创建窗口
window = MainWindow()
newWin = NewWindow()
# 显示窗口
window.show()
window.collec_btn.clicked.connect(newWin.show)
# 运行应用,并监听事件
sys.exit(app.exec_())

View file

@ -1,129 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2021/4/7
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: QQMenu
@description:
"""
import string
from random import choice, randint
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPainter, QFont, QIcon
from PyQt5.QtWidgets import QLabel, QMenu, QApplication
Style = """
QMenu {
/* 半透明效果 */
background-color: rgba(255, 255, 255, 230);
border: none;
border-radius: 4px;
}
QMenu::item {
border-radius: 4px;
/* 这个距离很麻烦需要根据菜单的长度和图标等因素微调 */
padding: 8px 48px 8px 36px; /* 36px是文字距离左侧距离*/
background-color: transparent;
}
/* 鼠标悬停和按下效果 */
QMenu::item:selected {
border-radius: 0px;
/* 半透明效果 */
background-color: rgba(232, 232, 232, 232);
}
/* 禁用效果 */
QMenu::item:disabled {
background-color: transparent;
}
/* 图标距离左侧距离 */
QMenu::icon {
left: 15px;
}
/* 分割线效果 */
QMenu::separator {
height: 1px;
background-color: rgb(232, 236, 243);
}
"""
def get_icon():
# 测试模拟图标
pixmap = QPixmap(16, 16)
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
painter.setFont(QFont('Webdings', 11))
painter.setPen(Qt.GlobalColor(randint(4, 18)))
painter.drawText(0, 0, 16, 16, Qt.AlignCenter,
choice(string.ascii_letters))
painter.end()
return QIcon(pixmap)
def about_qt():
# 关于Qt
QApplication.instance().aboutQt()
class Window(QLabel):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(400, 400)
self.setAlignment(Qt.AlignCenter)
self.setText('右键弹出菜单')
self.context_menu = QMenu(self)
self.init_menu()
def contextMenuEvent(self, event):
self.context_menu.exec_(event.globalPos())
def init_menu(self):
# 背景透明
self.context_menu.setAttribute(Qt.WA_TranslucentBackground)
# 无边框、去掉自带阴影
self.context_menu.setWindowFlags(
self.context_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint)
# 模拟菜单项
for i in range(10):
if i % 2 == 0:
action = self.context_menu.addAction('菜单 %d' % i, about_qt)
action.setEnabled(i % 4)
elif i % 3 == 0:
self.context_menu.addAction(get_icon(), '菜单 %d' % i, about_qt)
if i % 4 == 0:
self.context_menu.addSeparator()
if i % 5 == 0:
# 二级菜单
# 二级菜单
menu = QMenu('二级菜单 %d' % i, self.context_menu)
# 背景透明
menu.setAttribute(Qt.WA_TranslucentBackground)
# 无边框、去掉自带阴影
menu.setWindowFlags(menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint)
for j in range(3):
menu.addAction(get_icon(), '子菜单 %d' % j)
self.context_menu.addMenu(menu)
if __name__ == '__main__':
import sys
import cgitb
cgitb.enable(format='text')
app = QApplication(sys.argv)
app.setStyleSheet(Style)
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -1,66 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年3月28日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: QQSettingPanel
@description:
"""
try:
from PyQt5.QtWidgets import QApplication, QWidget
except ImportError:
from PySide2.QtWidgets import QApplication, QWidget
from Lib.SettingUi import Ui_Setting # @UnresolvedImport
class Window(QWidget, Ui_Setting):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.setupUi(self)
self.resize(700, 435)
self._blockSignals = False
# 绑定滚动条和左侧item事件
self.scrollArea.verticalScrollBar().valueChanged.connect(
self.onValueChanged)
self.listWidget.itemClicked.connect(self.onItemClicked)
def onValueChanged(self, value):
"""滚动条"""
if self._blockSignals:
# 防止item点击时改变滚动条会触发这里
return
for i in range(8): # 因为这里右侧有8个widget
widget = getattr(self, 'widget_%d' % i, None)
# widget不为空且在可视范围内
if widget and not widget.visibleRegion().isEmpty():
self.listWidget.setCurrentRow(i) # 设置item的选中
return
def onItemClicked(self, item):
"""左侧item"""
row = self.listWidget.row(item) # 获取点击的item的索引
# 由于右侧的widget是按照命名widget_0 widget_1这样比较规范的方法,可以通过getattr找到
widget = getattr(self, 'widget_%d' % row, None)
if not widget:
return
# 定位右侧位置并滚动
self._blockSignals = True
self.scrollArea.verticalScrollBar().setSliderPosition(widget.pos().y())
self._blockSignals = False
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
app.setStyleSheet(open('Data/style.qss', 'rb').read().decode('utf-8'))
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -1,65 +0,0 @@
from PyQt5.QtWidgets import QApplication, QWidget, QTextEdit, QVBoxLayout, QPushButton, QStackedLayout
import sys
class FormA(QWidget):
def __init__(self, parent=None):
super().__init__()
self.btnPress = QPushButton("Table AAAA")
layout = QVBoxLayout()
self.setLayout(layout)
layout.addWidget(self.btnPress)
self.setStyleSheet("background-color:green;")
class FormB(QWidget):
def __init__(self, parent=None):
super().__init__()
self.btnPress = QPushButton("Table BBBB")
layout = QVBoxLayout()
self.setLayout(layout)
layout.addWidget(self.btnPress)
self.setStyleSheet("background-color:red;")
class TextEditDemo(QWidget):
def __init__(self, parent=None):
super(TextEditDemo, self).__init__(parent)
self.setWindowTitle("QStackedLayout 例子")
self.resize(300, 270)
# 创建堆叠布局
self.btnPress1 = QPushButton("FormA")
self.btnPress2 = QPushButton("FormB")
self.form1 = FormA()
self.form2 = FormB()
widget = QWidget()
self.stacked_layout = QStackedLayout()
widget.setLayout(self.stacked_layout)
widget.setStyleSheet("background-color:grey;")
self.stacked_layout.addWidget(self.form1)
self.stacked_layout.addWidget(self.form2)
layout = QVBoxLayout()
layout.addWidget(widget)
layout.addWidget(self.btnPress1)
layout.addWidget(self.btnPress2)
self.setLayout(layout)
self.btnPress1.clicked.connect(self.btnPress1_Clicked)
self.btnPress2.clicked.connect(self.btnPress2_Clicked)
def btnPress1_Clicked(self):
self.stacked_layout.setCurrentIndex(0)
def btnPress2_Clicked(self):
self.stacked_layout.setCurrentIndex(1)
if __name__ == "__main__":
app = QApplication(sys.argv)
win = TextEditDemo()
win.show()
sys.exit(app.exec_())

View file

@ -1,31 +0,0 @@
import configparser
cfg_data = '''
[info]
users_dir= /home
name= $USER
home_dir= %(users_dir)s/%(name)s
'''
config = configparser.ConfigParser()
config.read_string(cfg_data)
users_dir = config['info']['users_dir']
name = config['info']['name']
home_dir = config['info']['home_dir']
print(users_dir)
print(name)
print(home_dir)
with open('../utils/test.ini', 'w') as config_file:
config.write(config_file)
config.add_section('Accounts')
config['Accounts']['baseUrl'] = 'https://cloud.liyp.cc'
config['Accounts']['name'] = 'admin'
config['Accounts']['type'] = 'NextCloud'
config['Accounts']['username'] = 'admin'
with open('../utils/test.ini', 'w') as config_file:
config.write(config_file)

View file

@ -1,98 +0,0 @@
import sys
from PyQt5 import QtCore, QtWidgets
class MainWindow(QtWidgets.QWidget):
switch_window = QtCore.pyqtSignal(str)
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setWindowTitle('Main Window')
layout = QtWidgets.QGridLayout()
self.line_edit = QtWidgets.QLineEdit()
layout.addWidget(self.line_edit)
self.button = QtWidgets.QPushButton('Switch Window')
self.button.clicked.connect(self.switch)
layout.addWidget(self.button)
self.setLayout(layout)
def switch(self):
self.switch_window.emit(self.line_edit.text())
class WindowTwo(QtWidgets.QWidget):
def __init__(self, text):
QtWidgets.QWidget.__init__(self)
self.setWindowTitle('Window Two')
layout = QtWidgets.QGridLayout()
self.label = QtWidgets.QLabel(text)
layout.addWidget(self.label)
self.button = QtWidgets.QPushButton('Close')
self.button.clicked.connect(self.close)
layout.addWidget(self.button)
self.setLayout(layout)
class Login(QtWidgets.QWidget):
switch_window = QtCore.pyqtSignal()
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setWindowTitle('Login')
layout = QtWidgets.QGridLayout()
self.button = QtWidgets.QPushButton('Login')
self.button.clicked.connect(self.login)
layout.addWidget(self.button)
self.setLayout(layout)
def login(self):
self.switch_window.emit()
class Controller:
def __init__(self):
pass
def show_login(self):
self.login = Login()
self.login.switch_window.connect(self.show_main)
self.login.show()
def show_main(self):
self.window = MainWindow()
self.window.switch_window.connect(self.show_window_two)
self.login.close()
self.window.show()
def show_window_two(self, text):
self.window_two = WindowTwo(text)
self.window.close()
self.window_two.show()
def main():
app = QtWidgets.QApplication(sys.argv)
controller = Controller()
controller.show_login()
sys.exit(app.exec_())
if __name__ == '__main__':
main()

View file

@ -1,9 +0,0 @@
import base64
password = '123456lyp'
later = base64.b64encode(password.encode('utf-8'))
print(later)
later1 = str(later, 'utf-8')
print(later1)
print(str(base64.b64decode(later1), 'utf-8'))

View file

@ -1,128 +0,0 @@
import os
import sys
from PyQt5 import QtWidgets
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import (
QApplication, QMainWindow,
QLabel, QGridLayout, QWidget,
QCheckBox, QSystemTrayIcon, QFormLayout,
QSpacerItem, QSizePolicy, QMenu, QAction, QStyle, QDialog, QPushButton, QMessageBox)
class MessageBox(QMessageBox):
def __init__(self):
super(MessageBox, self).__init__()
save_config = QCheckBox('记住选择')
self.layout().addWidget(save_config)
class SystemTray(QWidget):
def __init__(self):
super(SystemTray, self).__init__()
self.resize(500, 400)
# layout = QFormLayout()
# # self.setLayout(layout)
#
# label = QLabel('最小化到系统托盘?')
# layout.addRow(label)
# Init QSystemTrayIcon
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setIcon(QIcon(os.getcwd() + '/../images/todo_info.svg'))
# # self.style().standardIcon(QStyle.SP_ComputerIcon))
#
# self.checkbox = QCheckBox('最小化')
# layout.addWidget(self.checkbox)
'''
Define and add steps to work with the system tray icon
show - show window
hide - hide window
exit - exit from application
'''
show_action = QAction("显示", self)
quit_action = QAction("退出", self)
hide_action = QAction("隐藏", self)
show_action.triggered.connect(self.show)
hide_action.triggered.connect(self.hide)
quit_action.triggered.connect(QApplication.instance().quit)
tray_menu = QMenu()
tray_menu.addAction(show_action)
tray_menu.addAction(hide_action)
tray_menu.addAction(quit_action)
self.tray_icon.setContextMenu(tray_menu)
self.tray_icon.show()
# self.exit_widget = QWidget(self)
#
# self.exit_widget.setLayout(layout)
# 关闭窗口时弹出确认消息
def closeEvent(self, event):
# 创建一个消息盒子(提示框)
quitMsgBox = QMessageBox()
quitMsgBox.resize(300, 200)
# 设置提示框的标题
quitMsgBox.setWindowTitle('确认窗口')
# 设置提示框的内容
quitMsgBox.setText('你确定退出吗?')
# 创建两个点击的按钮,修改文本显示内容
buttonY = QPushButton('退出程序')
buttonN = QPushButton('最小化到托盘')
# 将两个按钮加到这个消息盒子中去并指定yes和no的功能
style = """
/*设置堆栈按钮样式*/
QPushButton {
/* padding: 3px 20px;*/
/* text-align:center;*/
background-color:orange;
border-radius:15px;
}
QPushButton:hover {
/* padding: 3px 20px;*/
/* text-align:center;*/
background-color:#dddddd;
border-radius:15px;
}
QPushButton:pressed {
/* padding: 3px 20px;*/
/* text-align:center;*/
background-color:#9f9f9f;
border-radius:15px;
}
"""
buttonY.setStyleSheet(style)
buttonN.setStyleSheet(style)
quitMsgBox.addButton(buttonY, QMessageBox.YesRole)
quitMsgBox.addButton(buttonN, QMessageBox.NoRole)
quitMsgBox.exec_()
# 判断返回值如果点击的是Yes按钮我们就关闭组件和应用否则就忽略关闭事件
if quitMsgBox.clickedButton() == buttonY:
event.accept()
else:
self.hide()
event.ignore()
# if self.checkbox.isChecked():
# event.ignore()
# self.hide()
# if self.check_box.isChecked():
# event.ignore()
# self.hide()
# self.tray_icon.showMessage(
# "Tray Program",
# "Application was minimized to Tray",
# QSystemTrayIcon.Information,
# 2000
# )
if __name__ == '__main__':
app = QApplication(sys.argv)
main = SystemTray()
main.show()
sys.exit(app.exec_())

View file

@ -1,57 +0,0 @@
import os
import json
import configparser
from utils import BasicUtils
def get_todo_list():
config_path = BasicUtils.return_work_dir()
todo_path = config_path + 'ToDoList/'
# print(todo_path)
# config = configparser.ConfigParser()
return_todo_list = []
for root, dirs, files in os.walk(todo_path, topdown=False):
for name in files:
# print(os.path.join(root, name))
with open(os.path.join(root, name), 'r') as f:
# print(f.read())
json_file = json.load(f)
# try:
if json_file['itemType'] == 'ToDoList':
# print(json_file['title'], json_file['uid'], '列表')
return_todo_list.append([json_file['title'], json_file['uid']])
# print(return_todo_list)
return return_todo_list
def get_to_do(todoListUid):
config_path = BasicUtils.return_work_dir()
todo_path = config_path + 'ToDoList/'
# print(todo_path)
# config = configparser.ConfigParser()
return_todo = []
for root, dirs, files in os.walk(todo_path, topdown=False):
for name in files:
# print(os.path.join(root, name))
with open(os.path.join(root, name), 'r') as f:
# print(f.read())
json_file = json.load(f)
# print(json_file['itemType'])
if json_file['itemType'] == 'Todo' and json_file['todoListUid'] == todoListUid:
# print(json_file['title'], json_file['uid'], '待办事项')
return_todo.append([json_file['title'], json_file['uid']])
return return_todo
# load_list = get_todo_list()
# print(load_list)
# if load_list:
# for load in load_list:
# print(load[0], load[1])
print(get_to_do('3f1e033f-2051-4c04-b7f6-afd2eb1f54f4'))

View file

@ -1,13 +0,0 @@
import datetime
import time
weekday = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
weekday_index = datetime.datetime.now().weekday()
month = datetime.datetime.now().month
day = datetime.datetime.now().day
print(datetime.datetime.now())
print(str(month) + '' + str(day) + '日,' + weekday[weekday_index])
time1 = '2022-04-17 20:39:10.242742'
time2 = datetime.datetime.now().strptime('2022-04-17 20:39:10', '%Y-%m-%d %H:%M:%S')
print(time2, type(time2))
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))

View file

@ -1,46 +0,0 @@
from watchdog.observers import Observer
from watchdog.events import *
import time
# todo : 实时检测文件变化,来同步文件
class FileEventHandler(FileSystemEventHandler):
def __init__(self):
FileSystemEventHandler.__init__(self)
def on_moved(self, event):
if event.is_directory:
print("directory moved from {0} to {1}".format(event.src_path, event.dest_path))
else:
print("file moved from {0} to {1}".format(event.src_path, event.dest_path))
def on_created(self, event):
if event.is_directory:
print("directory created:{0}".format(event.src_path))
else:
print("file created:{0}".format(event.src_path))
def on_deleted(self, event):
if event.is_directory:
print("directory deleted:{0}".format(event.src_path))
else:
print("file deleted:{0}".format(event.src_path))
def on_modified(self, event):
if event.is_directory:
print("directory modified:{0}".format(event.src_path))
else:
print("file modified:{0}".format(event.src_path))
if __name__ == "__main__":
observer = Observer()
event_handler = FileEventHandler()
observer.schedule(event_handler, os.path.expandvars('$HOME') + '/.config/PyQtToDoList/', True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()

View file

@ -1,354 +0,0 @@
import os
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt, pyqtSignal, QRect
from utils.BasicUtils import get_todo_list, remove_todo_list, change_value, read_ini, set_exit_status
from utils.CreateConfigure import CreateConfigure
from utils.CreateToDo import CreateToDo
from utils.QSSLoader import QSSLoader
from view.ImportantView import Important
from view.MyListWidget import MyListWidget
from view.ToDoListView import ToDoList
from view.UserLabel import User
from view.SelfListWidgetItem import SelfListWidgetItem
from view.AddListLabel import AddListAction
from view.MyDayView import MyDay
class MainWidget(QWidget):
update_signal = pyqtSignal()
init_signal = pyqtSignal()
def __init__(self):
super(MainWidget, self).__init__()
self.user_label = User()
self.create_config = CreateConfigure()
# 主布局,左右两侧
layout = QHBoxLayout()
# 子布局,左边的部分
self.sub_layout = QVBoxLayout()
self.sub_layout.spacing()
self.sub_layout.addWidget(self.user_label, 2)
# 左侧列表
self.system_listWidget = MyListWidget(self)
self.system_listWidget.setFrameShape(QListWidget.NoFrame)
self.sub_layout.addWidget(self.system_listWidget, 15)
# 添加最下边的QLabel
self.add_list_action = AddListAction()
self.add_list_action.create_todo_list.connect(self.create_item)
# self.add_item_label.setPixmap(QPixmap())
self.sub_layout.addWidget(self.add_list_action, 1)
# 禁止双击可编辑
self.system_listWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
# 右键菜单
self.system_listWidget.setContextMenuPolicy(Qt.CustomContextMenu)
self.system_listWidget.setObjectName('custom')
self.system_listWidget.customContextMenuRequested.connect(self.myListWidgetContext)
# 右侧层叠窗口
self.my_day = MyDay()
self.important = Important()
self.stackedWidget = QStackedWidget(self)
self.stackedWidget.addWidget(self.my_day)
self.stackedWidget.addWidget(self.important)
layout.addLayout(self.sub_layout, 2)
layout.addWidget(self.stackedWidget, 6)
self.system_listWidget.currentRowChanged.connect(self.stackedWidget.setCurrentIndex)
self.setLayout(layout)
self.user_label.sync_signal.connect(self.initUI)
# self.init_signal.connect(self.initUI)
self.initUI()
def initUI(self):
self.important.update_signal.connect(self.my_day.refresh_action)
self.my_day.update_signal.connect(self.important.refresh_action)
# 先清除列表,方便后面调用
self.system_listWidget.clear()
self.stackedWidget.window().close()
# 系统默认的两个 item
self.one_day = SelfListWidgetItem('我的一天', 0, None, os.getcwd() + '/../images/sun.svg')
self.system_listWidget.setCurrentRow(1)
self.important_item = SelfListWidgetItem('重要', 0, None, os.getcwd() + '/../images/star.svg')
self.system_listWidget.addItem(self.one_day)
self.system_listWidget.setItemWidget(self.one_day, self.one_day.widget)
self.system_listWidget.addItem(self.important_item)
self.system_listWidget.setItemWidget(self.important_item, self.important_item.widget)
# todo 通过信号修改显示的标题名字
# self.system_listWidget.change_list_name.connect(self.change_list)
# 加载列表
load_list = get_todo_list()
# print('<main>',load_list)
# todobug 第一次为空会导致无法添加
if load_list:
for load in load_list:
self.load_item(load[0], load[1], load[3])
# self.system_listWidget.addScrollBarWidget(False)
def myListWidgetContext(self, position):
if self.system_listWidget.currentRow() > 1:
# 设置右键菜单
pop_menu = QMenu(self)
pop_menu.setObjectName('lift_menu')
pop_menu.setAttribute(Qt.WA_TranslucentBackground)
# 无边框、去掉自带阴影
pop_menu.setWindowFlags(
pop_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint)
rename_action = QAction(u'重命名', self)
# copy_action = QAction("复制分组", self)
del_action = QAction("删除分组", self)
change_icon = QMenu('修改图标', pop_menu)
# 背景透明
change_icon.setAttribute(Qt.WA_TranslucentBackground)
# 无边框、去掉自带阴影
change_icon.setWindowFlags(
change_icon.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint)
# 二级菜单
action1 = QAction(QIcon(os.getcwd() + '/../images/icon/星宿.svg'), "星宿", self)
action2 = QAction(QIcon(os.getcwd() + '/../images/icon/度假.svg'), "度假", self)
action3 = QAction(QIcon(os.getcwd() + '/../images/icon/冰淇淋.svg'), "美食", self)
action4 = QAction(QIcon(os.getcwd() + '/../images/icon/学习.svg'), "学习", self)
action5 = QAction(QIcon(os.getcwd() + '/../images/icon/工作.svg'), "工作", self)
action6 = QAction(QIcon(os.getcwd() + '/../images/icon/购物.svg'), "购物", self)
change_icon.addAction(action1)
change_icon.addAction(action2)
change_icon.addAction(action3)
change_icon.addAction(action4)
change_icon.addAction(action5)
change_icon.addAction(action6)
action1.triggered.connect(lambda: self.change_icon('星宿'))
action2.triggered.connect(lambda: self.change_icon('度假'))
action3.triggered.connect(lambda: self.change_icon('冰淇淋'))
action4.triggered.connect(lambda: self.change_icon('学习'))
action5.triggered.connect(lambda: self.change_icon('工作'))
action6.triggered.connect(lambda: self.change_icon('购物'))
# 查看右键时是否在item上面,如果不在.就不显示删除和修改.
if self.system_listWidget.itemAt(position):
pop_menu.addAction(del_action)
pop_menu.addAction(rename_action)
# pop_menu.addAction(change_icon)
pop_menu.addMenu(change_icon)
rename_action.triggered.connect(self.rename_item)
# copy_action.triggered.connect(self.create_item)
del_action.triggered.connect(self.delete_item)
pop_menu.exec_(self.system_listWidget.mapToGlobal(position))
def change_icon(self, icon):
# print(icon)
load_list = get_todo_list()
change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'icon', icon)
self.initUI()
# 加载左侧列表
def load_item(self, list_name, uid, icon=None):
item = SelfListWidgetItem(list_name, 0, uid, os.getcwd() + '/../images/icon/' + icon + '.svg')
item.setTextAlignment(Qt.AlignCenter)
# 使得item是可以编辑的.
item.setFlags(item.flags() | Qt.ItemIsEditable)
self.system_listWidget.addItem(item)
todo_list = ToDoList(list_name, uid)
# 信号测试成功!!
# 更新 重要 内容
todo_list.update_signal.connect(self.important.refresh_action)
todo_list.update_signal.connect(self.my_day.refresh_action)
# 删除分组时可用
self.important.update_signal.connect(todo_list.refresh_action)
# self.important.update_signal.connect(self.my_day.refresh_action)
self.my_day.update_signal.connect(todo_list.refresh_action)
# self.my_day.update_signal.connect(self.important.refresh_action)
self.update_signal.connect(todo_list.refresh_action)
# 创建后就可以编辑item,用户自己起名字.
# self.system_listWidget.editItem(item)
self.stackedWidget.addWidget(todo_list)
self.system_listWidget.setItemWidget(item, item.widget)
# 点击创建新的分组
def create_item(self, new_list='新建列表', uid=None):
# 创建一个没有名字的item
# new_list = '新建列表'
if not uid:
create_todo_uid = CreateToDo('ToDoList', new_list)
item = SelfListWidgetItem(new_list, 0, create_todo_uid)
item.setTextAlignment(Qt.AlignCenter)
# 使得item是可以编辑的.
item.setFlags(item.flags() | Qt.ItemIsEditable)
self.system_listWidget.addItem(item)
todo_list = ToDoList(new_list, create_todo_uid)
self.stackedWidget.addWidget(todo_list)
self.system_listWidget.setItemWidget(item, item.widget)
# todo_list.update_signal.connect(self.initUI)
# 删除分组
def delete_item(self):
# print(self.load_list[self.system_listWidget.currentRow() - 2][1])
load_list = get_todo_list()
remove_todo_list(load_list[self.system_listWidget.currentRow() - 2][1])
self.system_listWidget.takeItem(self.system_listWidget.currentRow())
self.update_signal.emit()
# 重命名分组
def rename_item(self):
# curRow = self.todo_list.currentRow()
# item = self.todo_list.item(curRow)
self.dialog = QDialog()
self.dialog.setWindowTitle('重命名')
self.dialog_layout = QVBoxLayout()
self.dialog.resize(300, 200)
self.dialog.setLayout(self.dialog_layout)
line_edit = QLineEdit()
# line_edit.setObjectName('rename_line')
line_edit.setStyleSheet('border: 1px solid;background:transparent;min-width:400px;')
line_edit.setPlaceholderText('请输入新的名字')
self.dialog_layout.addWidget(line_edit)
confirm_button = QPushButton('确认修改')
self.dialog_layout.addWidget(confirm_button)
confirm_button.setStyleSheet('background-color:#bcbcbc;border-radius:5px;')
confirm_button.clicked.connect(lambda: self.change_name(line_edit.text()))
# self.system_listWidget.takeItem(self.system_listWidget.currentRow())
self.dialog.exec_()
def change_name(self, item_name):
# print(item_name)
if item_name:
load_list = get_todo_list()
change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'title', item_name)
self.update_signal.emit()
self.system_listWidget.takeItem(self.system_listWidget.currentRow())
# 重命名发送信号
self.initUI()
# self.update_signal.emit()
self.dialog.close()
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.resize(1150, 850)
self.setWindowTitle("待办事项")
# 主布局,用来显示主页面,设置页面等
self.layout = QStackedLayout(self)
self.main_widget = MainWidget()
# self.main_widget.resize(50, 200)
self.layout.addWidget(self.main_widget)
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setIcon(QIcon(os.getcwd() + '/../images/todo_info.svg'))
# # self.style().standardIcon(QStyle.SP_ComputerIcon))
#
# self.checkbox = QCheckBox('最小化')
# layout.addWidget(self.checkbox)
'''
Define and add steps to work with the system tray icon
show - show window
hide - hide window
exit - exit from application
'''
show_action = QAction("显示", self)
quit_action = QAction("退出", self)
hide_action = QAction("隐藏", self)
show_action.triggered.connect(self.show)
hide_action.triggered.connect(self.hide)
quit_action.triggered.connect(QApplication.instance().quit)
tray_menu = QMenu()
tray_menu.addAction(show_action)
tray_menu.addAction(hide_action)
tray_menu.addAction(quit_action)
self.tray_icon.setContextMenu(tray_menu)
self.tray_icon.show()
# self.exit_widget = QWidget(self)
#
# self.exit_widget.setLayout(layout)
# 关闭窗口时弹出确认消息
def closeEvent(self, event):
# 创建一个消息盒子(提示框)
quitMsgBox = QMessageBox()
# 设置气泡在屏幕上的位置水平居中垂直屏幕80%位置
# desktop = QApplication.desktop()
# quitMsgBox.setGeometry(QRect(int(desktop.width() / 2 - 75), int(desktop.height() * 0.5), 400, 300))
self.save_config = QCheckBox('记住选择')
self.save_config.setChecked(True)
quitMsgBox.setCheckBox(self.save_config)
# self.save_config.stateChanged.connect(self.save_exit)
quitMsgBox.resize(300, 200)
# 设置提示框的标题
quitMsgBox.setWindowTitle('确认窗口')
# 设置提示框的内容
quitMsgBox.setText('你确定退出吗?')
# 创建两个点击的按钮,修改文本显示内容
buttonY = QPushButton('退出程序')
buttonN = QPushButton('最小化到托盘')
# 将两个按钮加到这个消息盒子中去并指定yes和no的功能
style = QSSLoader.read_qss_file(os.getcwd() + '/../resource/closeDialog.qss')
buttonY.setStyleSheet(style)
buttonN.setStyleSheet(style)
quitMsgBox.addButton(buttonY, QMessageBox.YesRole)
quitMsgBox.addButton(buttonN, QMessageBox.NoRole)
exit_status = read_ini('System', 'exitstatus')
if exit_status == 'None':
# self.center(quitMsgBox)
quitMsgBox.exec_()
# 判断返回值如果点击的是Yes按钮我们就关闭组件和应用否则就忽略关闭事件
if quitMsgBox.clickedButton() == buttonY:
if self.save_config.isChecked():
set_exit_status('Exit')
event.accept()
else:
if self.save_config.isChecked():
set_exit_status('Min')
self.hide()
event.ignore()
elif exit_status == 'Exit':
event.accept()
elif exit_status == 'Min':
# print('Min')
self.hide()
event.ignore()
if __name__ == "__main__":
app = QApplication(sys.argv)
main = MainWindow()
main.setWindowTitle('PyQtToDoList')
# print(os.path.abspath('../'))
style_sheet = QSSLoader.read_qss_file(os.getcwd() + '/../resource/current.qss')
main.setStyleSheet(style_sheet)
app.setWindowIcon(QIcon(os.path.abspath('../') + '/images/todo_info.svg'))
main.show()
sys.exit(app.exec_())

View file

@ -1,87 +0,0 @@
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QApplication, QMainWindow, QStackedLayout, QWidget,
QToolBar, QToolButton, QStyle, QColorDialog, QFontDialog,
QVBoxLayout, QGroupBox, QRadioButton)
class DemoStackedLayout(QMainWindow):
def __init__(self, parent=None):
super(DemoStackedLayout, self).__init__(parent)
# 设置窗口标题
self.setWindowTitle('实战PyQt5: QStackedLayout Demo!')
# 设置窗口大小
self.resize(480, 360)
self.initUi()
def initUi(self):
toolBar = QToolBar(self)
self.addToolBar(Qt.LeftToolBarArea, toolBar)
btnColor = self.createButton('颜色对话框')
btnColor.clicked.connect(lambda: self.onButtonClicked(0))
toolBar.addWidget(btnColor)
btnFont = self.createButton('字体对话框')
btnFont.clicked.connect(lambda: self.onButtonClicked(1))
toolBar.addWidget(btnFont)
btnUser = self.createButton('分组部件')
btnUser.clicked.connect(lambda: self.onButtonClicked(2))
toolBar.addWidget(btnUser)
mainWidget = QWidget(self)
self.mainLayout = QStackedLayout(mainWidget)
# 添加三个widget,演示三个页面之间的切换
# 颜色对话框
self.mainLayout.addWidget(QColorDialog(self))
# 字体对话框
self.mainLayout.addWidget(QFontDialog(self))
# 自定义控件
self.mainLayout.addWidget(self.createExclusiveGroup())
mainWidget.setLayout(self.mainLayout)
# 设置中心窗口
self.setCentralWidget(mainWidget)
def createButton(self, text):
icon = QApplication.style().standardIcon(QStyle.SP_DesktopIcon)
btn = QToolButton(self)
btn.setText(text)
btn.setIcon(icon)
btn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
return btn
def onButtonClicked(self, index):
if index < self.mainLayout.count():
self.mainLayout.setCurrentIndex(index)
def createExclusiveGroup(self):
groupBox = QGroupBox('Exclusive Radio Buttons', self)
radio1 = QRadioButton('&Radio Button 1', self)
radio1.setChecked(True)
radio2 = QRadioButton('R&adio button 2', self)
radio3 = QRadioButton('Ra&dio button 3', self)
vLayout = QVBoxLayout(groupBox)
vLayout.addWidget(radio1)
vLayout.addWidget(radio2)
vLayout.addWidget(radio3)
vLayout.addStretch(1)
groupBox.setLayout(vLayout)
return groupBox
if __name__ == '__main__':
app = QApplication(sys.argv)
window = DemoStackedLayout()
window.show()
sys.exit(app.exec())

View file

@ -1,41 +0,0 @@
# import os
#
# for root, dir, files in os.walk(os.path.expandvars('$HOME') + '/.config/PyQtToDoList/'):
# for i in files:
# print(root, dir, files)
# # print(root)
# # print(dir)
import os
# 直接读取配置文件获取ToDo列表来选择备份文件不再选择同时获取文件和文件夹了
def file_name_walk(file_dir):
for root, dirs, files in os.walk(file_dir):
# print("root", root) # 当前目录路径
# print("dirs", dirs) # 当前路径下所有子目录
# print("files", files) # 当前路径下所有非目录子文件
print(len(files))
if dirs and files:
# print(True)
print(str(files[0]))
elif dirs and not files:
print(dirs[i] for i in range(len(dirs)))
else:
print(str(files[j] for j in range(len(files))))
# print(False)
# if
# if files :
# print(root + str(dirs[0]) + '/' + str(files[0]))
# else:
# print(root + str(files[0]))
file_name_walk(os.path.expandvars('$HOME') + '/.config/PyQtToDoList/')
# root ./
# dirs ['test']
# files ['200-2000(1).txt', '200-2000(2).txt', '200-2000(3).txt', 'getFileName.py']
# root ./test
# dirs []
# files ['test.txt']

View file

@ -1,15 +0,0 @@
from webdav3.client import Client
import configparser
options = {
'webdav_hostname': "https://dav.jianguoyun.com/dav/",
'webdav_login': "794508986@qq.com",
'webdav_password': "awncxpzjbgxxztbs"
}
client = Client(options)
# client.execute_request('list')
list1 = client.list('/')
print(list1)
exist = client.check('OpenTodoList')
print(exist)

View file

@ -1,11 +0,0 @@
[info]
users_dir = /home
name = $USER
home_dir = %(users_dir)s/%(name)s
[Accounts]
baseurl = https://cloud.liyp.cc
name = admin
type = NextCloud
username = admin