完整代码如下:
from PySide2.QtWidgets import QFileDialog, QDialog, QApplication, QMainWindow
class DlgSelectMp3(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
def selectMp3s(self):
fileNames = []
fileDialog = QFileDialog(self)
fileDialog.setViewMode(QFileDialog.Detail)
fileDialog.setFileMode(QFileDialog.ExistingFiles)
fileDialog.setNameFilter("python file(*.mp3);;all file(*)")
ret = fileDialog.exec_()
if ret == QDialog.Accepted:
fileNames = fileDialog.selectedFiles()
return fileNames
if __name__ == "__main__":
app = QApplication([])
dlgmw = DlgSelectMp3()
selectFiles = dlgmw.selectMp3s()
for it in selectFiles:
print(it)
app.exec_()
更多python代码,可以去这里看看:
该代码段展示了一个使用PySide2库创建的QFileDialog对话框,用于选择多个MP3文件。用户可以选择现有MP3文件,并通过 Detail 模式查看,过滤器设置为仅显示Python文件和所有文件。
1260

被折叠的 条评论
为什么被折叠?



