pyqt显示运行的主函数

主函数

if __name__ == "__main__":
    QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()  # ui_from是类名
    ui.setupUi(MainWindow)
    MainWindow.show()

sys.exit(app.exec_())

需要import的函数

import os
import sys
import numpy as np
import pandas as pd
from PyQt5.QtGui import QPainter, QPixmap, QColor, QFont
from matplotlib import pyplot as plt
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QFileDialog, QWidget, QApplication
import time
import tsfresh as tsf
from PyQt5.QtCore import Qt, QDateTime, QTimer
import statsmodels.tsa.stattools as sttools
from statsmodels.tsa.stattools import coint
from matplotlib.pylab import mpl
from statsmodels.tsa.tsatools import add_trend
from statsmodels.regression.linear_model import OLS

显示时间的函数

加在 setupUi函数之前,并在主函数中加入一句 ui.showTime() 进行调用

 def showTime(self):
        # 获取系统现在的时间
        time = QDateTime.currentDateTime()
        # 设置系统时间显示格式
        timeDisplay = time.toString("yyyy-MM-dd hh:mm:ss dddd");
        # 在标签上显示时间
        self.label.setText(timeDisplay)

你可能感兴趣的:(pyqt,python,开发语言)