pyqt_data_analysis/MainWindows.py

43 lines
2.0 KiB
Python
Raw Normal View History

2024-06-08 03:00:08 +08:00
import Ui_MainWindow
from PyQt5.QtCore import QFile, QFileInfo, pyqtSlot, pyqtSignal
from PyQt5 import QtGui, QtWidgets, QtCore
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtGui import QIcon, QPixmap
from data_set_read import Data_Read
class MainWindows:
def __init__(self) -> None:
self.MainWindow = QtWidgets.QMainWindow()
self.ui = Ui_MainWindow.Ui_MainWindow()
self.ui.setupUi(self.MainWindow)
self.window_ui_init()
self.file_object_init()
def window_ui_init(self):
self.MainWindow.setWindowTitle("Data Analysis By Python")
self.MainWindow.setWindowIcon(QIcon(QPixmap(":/src/image/icon.jpg")))
self.ui.progressBar_linear_regression.setValue(0)
def file_object_init(self):
self.ui.pushButton_filepath.clicked.connect(self.pushButton_filepath_clicked)
self.ui.pushButton_filepath_clear.clicked.connect(self.pushButton_filepath_clear_clicked)
self.ui.pushButton_linear_regression.clicked.connect(lambda checked: self.ui.stackedWidget.setCurrentIndex(0))
self.ui.pushButton_Kmeans.clicked.connect(lambda checked: self.ui.stackedWidget.setCurrentIndex(1))
def pushButton_filepath_clicked(self):
file_path = QtWidgets.QFileDialog.getOpenFileName(self.MainWindow, "Open File", ".", "All Files(*);;csv Files(*.csv);;Old Excel Files(*.xls);;New Excel Files(*.xlsx)")
print(file_path[0])
info = QFileInfo(file_path[0])
suffix = info.suffix()
if suffix == "csv":
#self.data_read = Data_Read(file_path[0], suffix)
self.ui.lineEdit_filepath.setText(file_path[0])
elif suffix == "xls" or suffix == "xlsx":
#self.data_read = Data_Read(file_path[0], suffix)
self.ui.lineEdit_filepath.setText(file_path[0])
# if file_path is not None:
# self.ui.lineEdit_filepath.setText(file_path)
def pushButton_filepath_clear_clicked(self):
self.ui.lineEdit_filepath.clear()