定义一个button
self.pushButton.setObjectName("pushButton")
self.toolButton = QtWidgets.QToolButton(self.centralwidget)
self.toolButton.setGeometry(QtCore.QRect(1130, 480, 141, 22))
self.toolButton.setObjectName("toolButton")
self.toolButton.clicked.connect(self.msg)
定义一个函数
def msg(self, Filepath):
# 点击按钮出现文件夹位置
directory_path = QtWidgets.QFileDialog.getExistingDirectory(None, "选取文件夹", "C:/") # 起始路径
return directory_path