代码拉取完成,页面将自动刷新
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_())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。