PYQT5(十七)打开文件目录
2018-12-08 本文已影响864人
弗兰克万岁
打开文件目录选择一个文件夹
def setPicPath(self):
path=self.load_last_path()
file=QDialog()
fname,ftype=QFileDialog.getOpenFileName(file,'open',path)
print(fname)
if fname:
res = self.save_last_path(fname)
if res == 0:
print('false occured in path saving processing')
如果要获取地址或者别的可以试试下面这些函数

getOpenFileNames 获取多个文件的地址,返回的是一个数组
getOpenFileUrl 返回PyQt5.QtCore.QUrl 对象,不知道什么用途