PYQT5实现文件目录浏览

 1. 选取文件夹 QFileDialog.getExistingDirectory()  #返回字符串
 2. 选择文件 QFileDialog.getOpenFileName()   #返回元组
 3. 选择多个文件 QFileDialog.getOpenFileNames()
 4. 选择保存文件 QFileDialog.getSaveFileName()

示例:

    def setBrowerPath(self): 
        download_path = QtWidgets.QFileDialog.getExistingDirectory(self,  
                                    "浏览",  
                                    "E:\workspace")   
        self.lineEdit.setText(download_path) 
发布了34 篇原创文章 · 获赞 54 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_42686768/article/details/89786497