Tkinter File Dialog Question
Steve Zatz
slzatz at hotmail.com
Mon Nov 4 08:01:16 EST 2002
Jorgen,
Thanks much for the response. I wasn't aware that there was a
defaultextension option. Unfortunately, it doesn't quite solve my
problem. I am providing the users with several extension options (eg
xml, txt) and they are selecting one of those options and then
(understandably) creating a file name without an extension assuming
that it will pick up the extension they have selected. However, I
don't see any way to get at their extension selection since the Dialog
only seems to return the filename they input.
> you can use the option: 'defaultextension'. Example
>
> >>> import tkFileDialog
> >>> res = tkFileDialog.asksaveasfilename(defaultextension=".txt")
> (user types in "myfilename")
> >>> res
> 'myfilename.txt'
>
> Remember the dot in the extension string. I just tried and it works,
> unless the user selects a filename that already exist.
>
> Regards
> Jorgen Cederberg
More information about the Python-list
mailing list