Question about asksaveasfilename

Mike Callahan mcalla at insightbb.com
Sun Jun 16 16:13:24 EDT 2002


I did find defaultextension, but as you pointed out, it only works with a
single string and does not pay attention to the user's choice in the file
type listbox. I guess I could make my own dialog but I thought that built-in
one would do the trick. Since no one else has responded, I guess it cannot.

Mike C.

"Eric Brunel" <eric.brunel at pragmadev.com> wrote in message
news:aea3ha$lv$1 at wanadoo.fr...
> Mike Callahan wrote:
>
> > I am using asksaveasfilename from tkFileDialog. I want to restrict my
> > users to save filenames with these extensions .unl or .sql. This is my
> > call:
> >
> > from tkFileDialog import asksaveasfilename
> > fn = asksaveasfilename(filetypes=[('Unloaded', '*.unl'),
> > ('Queries','*.sql')])
> >
> > This gives me the correct dialog box, but how do I force the correct
> > extension on fn?  Thanks.
>
> There's a defaultextension option, but it does not depend on the selected
> file type, i.e. you'll have to do either:
>
> fn = asksaveasfilename(filetypes=[('Unloaded', '*.unl'),
>                                   ('Queries',  '*.sql')],
>                        defaultextension='.unl')
>
> or:
>
> fn = asksaveasfilename(filetypes=[('Unloaded', '*.unl'),
>                                   ('Queries',  '*.sql')],
>                        defaultextension='.sql')
>
> which isn't what you're looking for, I fear...
>
> I don't know any means to force an extension depending on the selecetd
file
> type with asksaveasfilename, so my advice would be to split the two save
> options: one "Save unloaded" and one "Save query"... But if there's
another
> solution, I'm interested too ;-).
>
> HTH
> --
> - Eric Brunel <eric.brunel at pragmadev.com> -
> PragmaDev : Real Time Software Development Tools -
http://www.pragmadev.com





More information about the Python-list mailing list