Reputation: 55
I created a filechooserdialog
to save files,
filechooserdialog = gtk.FileChooserDialog("Save Project", None,
gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OK, gtk.RESPONSE_OK))
Now I want to save file with a default extension, say *.xyz
.
Upvotes: 1
Views: 1017
Reputation: 57890
Check out the documentation on gtk.FileFilter
. Create a filter for *.xyz and add it to the dialog with filechooserdialog.add_filter()
.
EDIT: If you want to ensure that the file has the proper extension, simply do this:
filename = filechooserdialog.get_filename()
if not filename.endswith('.xyz'):
filename += '.xyz'
Upvotes: 2