Take the 2-minute tour ×

I would like to use the simplest library to choose a file in local directories. My program has nothing to do with a fancy user interface. It can take all the input from the console. I don't want users to enter an entire path to the console. That's the only point I need a simple user interface. Can you suggest me a simple, cross platform python library for this purpose. Thanks in advance.

share|improve this question

closed as off-topic by David Cain, David, greg-449, Stephane Rolland, wheaties Dec 26 '13 at 15:42


  • "Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – David Cain, David, greg-449, Stephane Rolland, wheaties

This questions will invite answers recommending a simple, cross platform python library. Not a good question. There will be a lot of different answers and so on. –  leonneo Dec 26 '13 at 12:37

5 Answers 5

up vote 63 down vote accepted

How about using Tkinter?

from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file


share|improve this answer
thank you very much –  Mustafa Zengin Aug 26 '10 at 21:27
I got TypeError: 'module' object is not callable on Tk().withdraw() - any ideas? –  user391339 Feb 18 at 20:58
I had to do root = Tk.Tk() then root.withdraw(). Now the open file dialog window does not close however. –  user391339 Feb 18 at 21:07

Python 3.x version of Etaoin's answer for completeness:

from tkinter.filedialog import askopenfilename
filename = askopenfilename()
share|improve this answer

Use the tkFileDialog module which is part of the standard installation.

import tkFileDialog

print tkFileDialog.askopenfilename()
share|improve this answer

Another option to consider is Zenity: http://freecode.com/projects/zenity.

I had a situation where I was developing a Python server application (no GUI component) and hence didn't want to introduce a dependency on any python GUI toolkits, but I wanted some of my debug scripts to be parameterized by input files and wanted to visually prompt the user for a file if they didn't specify one on the command line. Zenity was a perfect fit. To achieve this, invoke "zenity --file-selection" using the subprocess module and capture the stdout. Of course this solution isn't Python-specific.

Zenity supports multiple platforms and happened to already be installed on our dev servers so it facilitated our debugging/development without introducing an unwanted dependency.

share|improve this answer

With EasyGui (documentation generated by pydoc and epydoc for version 0.96):

import easygui
print easygui.fileopenbox()

To install:

pip install http://easygui.sourceforge.net/download/version0.96/easygui_v0.96.zip


import easygui
share|improve this answer
