Issue
I have looked out through bunch of code but this peace of code doesn't work as expected for me:
export_dialog = QtGui.QFileDialog()
export_dialog.setWindowTitle('Export')
export_dialog.setDirectory(EXPORT_DIR)
export_dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
export_dialog.setNameFilter('INI files (*.ini)')
export_dialog.setDefaultSuffix('ini')
export_file, _ = export_dialog.getSaveFileName()
print(export_file)
I'm saving my file without extension, counting on that my above configurations will set it properly, but it doesn't work. There is no extension added.
Any suggestions?
Thanks
Solution
export_dialog = QtGui.QFileDialog()
export_dialog.setWindowTitle('Export')
export_dialog.setDirectory(EXPORT_DIR)
export_dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
export_dialog.setNameFilter('INI files (*.ini)')
export_dialog.setDefaultSuffix('ini')
if export_dialog.exec_() == QtGui.QFileDialog.Accepted:
print(export_dialog.selectedFiles()[0])
This code will return a full file path with selected filter also.
Answered By - Achayan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.