Selecting a file in a directory

Steven D'Aprano steve at
Sun Feb 14 02:45:03 CET 2010

On Sat, 13 Feb 2010 17:21:51 -0800, vsoler wrote:

> Hi,
> My python script needs to work with a .txt file in a directory. I would
> like to give the user the possibility to choose the file he needs to
> work on in as much the same way as I open a .xls file in Excel, that is,
> I want to make appear the "Windows'" window and let the user choose.
> I think this should be quite straightforward.

Python is multi-platform. Having the Windows file selection dialogs 
appear under Linux or Mac is anything but straightforward! The only 
general purpose (non-operating system specific) solution will require a 
GUI toolkit.

> How should I proceed?

>>> import tkFileDialog
>>> help(tkFileDialog)

See also:

or google on "python display file dialog".


More information about the Python-list mailing list