相关文章推荐
pyqt5计时器的使用
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QAction, QLabel, QLineEdit, QPushButton
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QTextEdit, QTextBrowser, QHBoxLayout, QVBoxLayout
import time
class Train_UI(QWidget):
    def __init__(self,parent=None,*args,**kwargs):
        super().__init__(parent,*args,**kwargs)
        self.iniUI()
    def iniUI(self):
        self.setWindowTitle("模型训练")
        self.resize(800, 600)
        # self.browser_label = QLabel('QTextBrowser', self)
        # self.text_edit = QTextEdit(self)
        self.text_browser = QTextBrowser(self)
        self.text_browser.move(200, 70)
        self.text_browser.resize(400, 400)
        self.text_browser.setText("")
        self.label_confi = QLabel(self)
        self.label_confi.move(350,30)
        self.label_confi.setText("训练日志")
        btn1 = QPushButton("开始训练", self)
        btn1.move(650, 450)
        lb1 = QLabel(self)
        lb1.setText("Epoch:")
        lb1.move(30,240)
        le = QLineEdit(self)
        le.resize(80,30)
        le.move(80,240)
        lb1 = QLabel(self)
        lb1.setText("Lr:")
        lb1.move(30,200)
        le = QLineEdit(self)
        le.resize(80,30)
        le.move(80,200)
        lb1 = QLabel(self)
        lb1.setText("batchsize:")
        lb1.move(30,160)
        le = QLineEdit(self)
        le.resize(80,30)
        le.move(108,160)
        # lb1 = QLabel(self)
        # lb1.setText("训练集路径:")
        # lb1.move(30,500)
        # le = QLineEdit(self)
        # le.resize(600,30)
        # le.move(120,500)
        # lb1 = QLabel(self)
        # lb1.setText("测试集路径:")
        # lb1.move(30,550)
        # le = QLineEdit(self)
        # le.resize(600,30)
        # le.move(120,550)
        # print(qle.text())
        btn1.clicked.connect(self.buttonClicked)
    def buttonClicked(self):
        import os
        os.system(r"E:\kg\TURN-TAP-master\turn_codes\main.py")
        self.startTimer(2000)
    def timerEvent(self, evt) :
        f = open(r"E:\kg\TURN-TAP-master\turn_codes\train_info.txt", 'r')
        with f:
            data = f.read()
            self.text_browser.setText(data)
if __name__ == '__main__':
    app = QApplication(sys.argv)
    gui = Train_UI()
    timer_id = gui.startTimer(2000)
    gui.killTimer(timer_id)
    gui.show()
    sys.exit(app.exec_())