PyQt文件选择
作者:互联网
使用下面的代码,可以实现文件的选择。这里以CSV格式文件为例:
from PySide6.QtWidgets import QApplication, QFileDialog, QWidget
def selectFile(parent: QWidget) -> str:
return QFileDialog.getOpenFileName(
parent, "Choose File", "./",
"Comma-Separated Values (*.csv);;All Files (*)")[0]
def saveFile(parent: QWidget) -> str:
return QFileDialog.getSaveFileName(
parent, "Choose Data File", "./",
"Comma-Separated Values (*.csv);;")[0]
标签:Separated,文件,QFileDialog,parent,PyQt,选择,Choose,QWidget,csv 来源: https://www.cnblogs.com/fang-d/p/PyQt_File_Selection.html