美文网首页
pyside2如何选择多个文件夹

pyside2如何选择多个文件夹

作者: 飞入蓝天 | 来源:发表于2021-08-06 13:37 被阅读0次

    完整代码如下:

    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

    相关文章

      网友评论

          本文标题:pyside2如何选择多个文件夹

          本文链接:https://www.haomeiwen.com/subject/aoawvltx.html