完整代码如下:
from PySide2.QtWidgetsimport 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 itin selectFiles:
print(it)
app.exec_()
更多python代码,可以去这里看看
http://kbase.wave12.com/pythoncode
网友评论