1 Star 0 Fork 0

陈柏居/TimeRecorder

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 3.03 KB
一键复制 编辑 原始数据 按行查看 历史
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from functools import partial
# 使用pyuic5 CBJTest.ui -o CBJui.py生成
from CBJui import *
import inputAnalyze
import recorder
def checkInputData(ui):
# check time
date = ui.calendar.selectedDate().toString("yyMMdd")
time = ui.lineEditTime.text()
if time == '':
time = recorder.getFmtTime()
timer = recorder.CBJTimeRW()
timer.checkDateTime(date, time)
def onBreakPoint(ui):
try:
checkInputData(ui)
timer = recorder.CBJTimeRW()
timer.setBreakPoint(endDate=ui.calendar.selectedDate().toString("yyMMdd"),
endTime=ui.lineEditTime.text(),
comment=ui.lineEditComment.text())
onRefresh(ui)
except Exception as e:
print(e.args, e.with_traceback(None))
def onStart(ui):
try:
checkInputData(ui)
timer = recorder.CBJTimeRW()
timer.setLastStart(attributeNum=inputAnalyze.analyzeAttribute(ui),
startDate=ui.calendar.selectedDate().toString("yyMMdd"),
startTime=ui.lineEditTime.text(),
comment=ui.lineEditComment.text())
onRefresh(ui)
except Exception as e:
print(e.args, e.__traceback__, e.__dict__)
def onEnd(ui):
try:
checkInputData(ui)
timer = recorder.CBJTimeRW()
timer.setLastEnd(attributeNum=inputAnalyze.analyzeAttribute(ui),
endDate=ui.calendar.selectedDate().toString("yyMMdd"),
endTime=ui.lineEditTime.text(),
comment=ui.lineEditComment.text())
onRefresh(ui)
except Exception as e:
print(e.args, e.__traceback__)
def onRefresh(ui):
try:
timer = recorder.CBJTimeRW()
lines = timer.readLastText()
# print(lines)
ui.textEdit.setText(''.join(lines))
except Exception as e:
print(e.args, e.__traceback__)
def onClear(ui: Ui_MainWindow):
ui.lineEditTime.clear()
def onTest(ui: Ui_MainWindow):
print(ui.textEdit.toPlainText())
b = hex(inputAnalyze.analyzeAttribute(ui))[2:].upper()
print(b)
a = ui.calendar.selectedDate()
print(a.toString("yyMMdd"))
print(a)
print(type(a))
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = QMainWindow()
uiMainWindow = Ui_MainWindow()
uiMainWindow.setupUi(MainWindow)
MainWindow.show()
# 添加配置
# 传参, 可以传具体的参数, 也可以直接传ui
uiMainWindow.buttonEnd.clicked.connect(partial(onEnd, uiMainWindow))
uiMainWindow.buttonTest.clicked.connect(partial(onTest, uiMainWindow))
uiMainWindow.buttonStart.clicked.connect(partial(onStart, uiMainWindow))
uiMainWindow.buttonRefresh.clicked.connect(partial(onRefresh, uiMainWindow))
uiMainWindow.buttonBreakPoint.clicked.connect(partial(onBreakPoint, uiMainWindow))
uiMainWindow.buttonClear.clicked.connect(partial(onClear, uiMainWindow))
onRefresh(uiMainWindow)
sys.exit(app.exec_())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chen-boju/time-recorder.git
git@gitee.com:chen-boju/time-recorder.git
chen-boju
time-recorder
TimeRecorder
master

搜索帮助