dialog.setFileMode(QtGui.QFileDialog.Directory)
dialog.setOption(QtGui.QFileDialog.ShowDirsOnly, True)
if dialog.exec_():
    for d in dialog.selectedFiles():
        pass
Making File Dialog only accept directories