0

I am trying to get the User to select a destination directory for some files the code will create later; the chosen directory will be stored by the code until needed. I can code for a file name (code below), but I don't know how to code for just the directory. Is there something like '.getOpenDirectoryName()', or do I need a different approach?

    default_file_path, _ = QtWidgets.QFileDialog.getOpenFileName(
        None, "Select Defaults File", "", "Default Files (*.txt)")
    if default_file_path == '':
        msgBox = QtWidgets.QMessageBox()
        msgBox.setText("No file selected")
        msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok)
        msgBox.setIcon(QtWidgets.QMessageBox.Warning)
        msgBox.exec_()
WillH
  • 281
  • 2
  • 13

1 Answers1

0

Answer found in the comments on a previous Q&A. how to have a directory dialog

folder = str(QFileDialog.getExistingDirectory(None, "Select Directory")) 
WillH
  • 281
  • 2
  • 13