使用方式:
selectedFile = QFileDialog.getOpenFileName(self,
"Select one file to open",
"/home",'Docement ( *.pdf )')
其调用结果为此外,返回值selectedFile 是一个元组(显示在plaintext里面):
源代码为:
selectedFile = QFileDialog.getOpenFileName(self, "Select one file to open",
"/home","Docement ( *.pdf )")
self.plainTextEdit.appendPlainText( str( len(selectedFile) ) )
self.plainTextEdit.appendPlainText( str( selectedFile ) )
选择多个文件的对话框使用方式为:
selectedFiles = QFileDialog.getOpenFileNames(self,
"Select one file to open",
"/home",'Docement ( *.pdf )')
此时运行结果为:
selectedFiles 依旧是两个元素的元组,但是第一个元素变为了文件路径的列表