Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Last active May 29, 2020 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasG77/440006f4c5f88bd38dfabc84beb699d5 to your computer and use it in GitHub Desktop.
Save ThomasG77/440006f4c5f88bd38dfabc84beb699d5 to your computer and use it in GitHub Desktop.
from qgis.PyQt.QtWidgets import QFileDialog
dialog = QFileDialog()
# dialog.setNameFilters(["Log files (*.log)"])
dialog.setFileMode(QFileDialog.DirectoryOnly);
dialog.setOption(QFileDialog.ShowDirsOnly, False);
def fileSelected(file):
# Instead of printing, save it in a config in your plugin
print(file)
dialog.fileSelected.connect(fileSelected)
dialog.show() # Select a directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment