From 721f623c34caad9a4902a7cee17d3b7b52e0d21a Mon Sep 17 00:00:00 2001 From: bd6oc Date: Wed, 19 Nov 2025 12:28:40 +0800 Subject: [PATCH] first commit --- excel_split.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 excel_split.py diff --git a/excel_split.py b/excel_split.py new file mode 100644 index 0000000..b413eb4 --- /dev/null +++ b/excel_split.py @@ -0,0 +1,42 @@ +import sys +from PySide6 import QtCore, QtGui, QtWidgets +from PySide6.QtUiTools import QUiLoader +from pathlib import Path +from PySide6.QtWidgets import QFileDialog, QMainWindow + + +class MainWindows(QMainWindow): + UI_FILE = 'ui/main_window.ui' + def __init__(self): + super(MainWindows, self).__init__() + + self.ui = QUiLoader().load(self.UI_FILE) + + self.ui.SelectFileBtn.clicked.connect(self.select_excel_file) + + # 点击选择文件按钮后,弹出选择EXCEL窗口。 + def select_excel_file(self): + # 弹窗标题 + caption = "请选择EXCEL文件" + # 起始目录 + start_dir = str(Path.home()) + # 文件类型过滤器 + filters = "Excel 文件 (*.xlsx *.xls);;所有文件 (*.*)" + # 选择EXCEL文件 + file_path, _ = QFileDialog.getOpenFileName(None, caption, start_dir, filters) + + if file_path: + self.ui.FileNameEdt.setText(str(file_path)) + print(file_path) + + +if __name__ == '__main__': + UI_FILE = "uv/main_window.ui" + app = QtWidgets.QApplication(sys.argv) + # 设置应用程序样式 + app.setStyle("Fusion") + + main = MainWindows() + main.ui.show() + sys.exit(app.exec()) +