基础功能实现!

This commit is contained in:
liyp 2022-03-02 22:28:55 +08:00
parent d2cae60b4f
commit 294bcbc97b
4 changed files with 168 additions and 0 deletions

3
images/pause.svg Normal file
View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pause-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM6.25 5C5.56 5 5 5.56 5 6.25v3.5a1.25 1.25 0 1 0 2.5 0v-3.5C7.5 5.56 6.94 5 6.25 5zm3.5 0c-.69 0-1.25.56-1.25 1.25v3.5a1.25 1.25 0 1 0 2.5 0v-3.5C11 5.56 10.44 5 9.75 5z"/>
</svg>

After

Width:  |  Height:  |  Size: 361 B

3
images/play.svg Normal file
View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM6.79 5.093A.5.5 0 0 0 6 5.5v5a.5.5 0 0 0 .79.407l3.5-2.5a.5.5 0 0 0 0-.814l-3.5-2.5z"/>
</svg>

After

Width:  |  Height:  |  Size: 276 B

1
images/stand.svg Normal file
View file

@ -0,0 +1 @@
<svg height="64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" style="width: 64px; height: 64px;"><g><path d="M38.808,11.191C38.808,5.009,43.818,0,50,0s11.192,5.01,11.192,11.191S56.181,22.383,50,22.383 S38.808,17.373,38.808,11.191z M90.627,27.367c-0.003-0.009-0.006-0.018-0.01-0.025c-0.826-2.086-3.184-3.117-5.277-2.303 l-12.568,6.936c0,0-11.58-7.822-22.771-7.822c-11.192,0-22.771,7.822-22.771,7.822l-12.568-6.936 c-2.095-0.814-4.452,0.217-5.278,2.303c-0.003,0.008-0.006,0.017-0.01,0.025c-0.817,2.102,0.224,4.47,2.328,5.287l14.58,7.718 c1.259,0.489,2.678,0.325,3.792-0.438l8.849-5.268v60.303c0,2.777,2.272,5.031,5.076,5.031s5.075-2.254,5.075-5.031V65.678h1.857 v29.291c0,2.777,2.272,5.031,5.075,5.031s5.076-2.254,5.076-5.031V34.666l8.849,5.268c1.114,0.764,2.532,0.928,3.792,0.438 L88.3,32.654C90.403,31.836,91.445,29.468,90.627,27.367z"></path></g></svg>

After

Width:  |  Height:  |  Size: 949 B

161
main.py Normal file
View file

@ -0,0 +1,161 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'sit_reminder.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.
import notify2
import schedule
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtGui import QIntValidator, QIcon
from PyQt5.QtCore import QThread, pyqtSignal
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(344, 400)
MainWindow.setMinimumSize(QtCore.QSize(344, 400))
MainWindow.setMaximumSize(QtCore.QSize(344, 400))
# icon = QtGui.QIcon()
# icon.addPixmap(QtGui.QPixmap(":/icon/images/stand.svg"), QtGui.QIcon.Normal, QtGui.QIcon.On)
# MainWindow.setWindowIcon(icon)
MainWindow.setIconSize(QtCore.QSize(64, 64))
self.centralwidget = QtWidgets.QWidget(MainWindow)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
self.centralwidget.setMaximumSize(QtCore.QSize(600, 400))
self.centralwidget.setAutoFillBackground(False)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.start = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.start.sizePolicy().hasHeightForWidth())
self.start.setSizePolicy(sizePolicy)
# self.start.setStyleSheet("border-image: url(:/image/images/play.svg);\n"
# "border-image: url(:/image/images/pause.svg);")
self.start.setIconSize(QtCore.QSize(32, 32))
self.start.setAutoExclusive(False)
self.start.setObjectName("start")
self.gridLayout.addWidget(self.start, 10, 2, 1, 1)
self.thirty = QtWidgets.QPushButton(self.centralwidget)
self.thirty.setObjectName("thirty")
self.gridLayout.addWidget(self.thirty, 5, 0, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 11, 2, 1, 1)
self.sixty = QtWidgets.QPushButton(self.centralwidget)
self.sixty.setObjectName("sixty")
self.gridLayout.addWidget(self.sixty, 5, 4, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem1, 4, 2, 1, 1)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem2, 2, 2, 1, 1)
spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem3, 6, 2, 1, 1)
self.time = QtWidgets.QLineEdit(self.centralwidget)
self.time.setAlignment(QtCore.Qt.AlignCenter)
self.time.setObjectName("time")
self.gridLayout.addWidget(self.time, 7, 2, 1, 1)
spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem4, 0, 2, 1, 1)
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem5, 1, 0, 1, 1)
self.selectTime = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(25)
self.selectTime.setFont(font)
self.selectTime.setAlignment(QtCore.Qt.AlignCenter)
self.selectTime.setObjectName("selectTime")
self.gridLayout.addWidget(self.selectTime, 1, 1, 1, 3)
spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem6, 1, 4, 1, 1)
self.ten = QtWidgets.QPushButton(self.centralwidget)
self.ten.setObjectName("ten")
self.gridLayout.addWidget(self.ten, 3, 4, 1, 1)
self.one = QtWidgets.QPushButton(self.centralwidget)
self.one.setObjectName("one")
self.gridLayout.addWidget(self.one, 3, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.one.clicked.connect(lambda: self.setTime('1'))
self.ten.clicked.connect(lambda: self.setTime('10'))
self.thirty.clicked.connect(lambda: self.setTime('30'))
self.sixty.clicked.connect(lambda: self.setTime('60'))
# 限制输入范围为 1,240
self.time.setPlaceholderText('请输入整数')
val = QIntValidator()
val.setRange(1, 240)
self.time.setValidator(val)
self.start.clicked.connect(self.startBtn)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "提醒小助手"))
self.start.setText(_translate("MainWindow", "开始"))
self.thirty.setText(_translate("MainWindow", "30分"))
self.sixty.setText(_translate("MainWindow", "60分"))
self.selectTime.setText(_translate("MainWindow", "选择时长"))
self.ten.setText(_translate("MainWindow", "10分"))
self.one.setText(_translate("MainWindow", "1分"))
def setTime(self, text):
self.time.setText(text)
def startBtn(self):
self.thread = Work()
self.thread.setTime(self.time.text())
self.thread.start()
# import apprcc_rc
class Work(QThread):
signal = pyqtSignal()
def __init__(self):
super(Work, self).__init__()
def setTime(self, timeset):
self.timeset = timeset
def job(self):
title = '休息助手 '
message = '该起来动一下了!'
# subprocess.Popen(['notify-send', title+message])
notify2.init(title)
n = notify2.Notification(title, message)
n.show()
def run(self):
self.timeset = int(self.timeset)
schedule.every(self.timeset).minutes.do(self.job)
while True:
schedule.run_pending()
QThread.sleep(1)
import sys
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setWindowIcon(QIcon('./images/stand.svg'))
main = QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(main)
main.show()
sys.exit(app.exec_())