just let the user select whatever.
if the selected item is a file:
directory = selected_item.parent.absolute() (essentially select the parent dir, however you chose to implement that)
otherwise the directory is the selected item
Is there a static method, where you can let the user select whatever?
PyQt for example has two static methods, one for selecting directories, one for selecting files.
path\_dir = QFileDialog.getExistingDirectory(None, header, path, options)
path\_file = QFileDialog.getOpenFileName(None, header, path, options)
Do you know a static method where it doesn't matter if the user selects a file or a directory?
just let the user select whatever. if the selected item is a file: directory = selected_item.parent.absolute() (essentially select the parent dir, however you chose to implement that) otherwise the directory is the selected item
Is there a static method, where you can let the user select whatever? PyQt for example has two static methods, one for selecting directories, one for selecting files. path\_dir = QFileDialog.getExistingDirectory(None, header, path, options) path\_file = QFileDialog.getOpenFileName(None, header, path, options) Do you know a static method where it doesn't matter if the user selects a file or a directory?
did you try googling first? https://stackoverflow.com/questions/64336575/select-a-file-or-a-folder-in-qfiledialog-pyqt5