opening 'file open' dialog from console

Phlip phlip_cpp at yahoo.com
Tue Sep 3 00:38:24 EDT 2002


dsavitsk wrote:

> I would like to open a file open dialog from a console on windows (2000).
> I do this now using the line
> 
>>>> from tkFileDialog import *
>>>> fileName = askopenfilename(filetypes=[(".txt", ".txt")], title="Select
> the file")
> 
> but this opens a second window and leaves it there.  what is the best way
> (tkinter or MFC) to do this w/o the second window?

Fetch the root singleton (or whatever it is) out of Tk land:

        root = Tk()

Withdraw it:

        root.withdraw()

Warning: Sometimes this withdraws the wrong thing. >sigh<

Alternately, pass it into 'askopenfilename', if possible.

-- 
  Phlip
          http://www.greencheese.org/ParodyMode
  --  Have a :-) day  --




More information about the Python-list mailing list