views:

95

answers:

4

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.

A: 

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

import tkFileDialog

print tkFileDialog.askopenfilename()
PreludeAndFugue
+11  A: 

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
print(filename)

Done!

Etaoin
thank you very much
Mustafa Zengin
A: 

EasyGui:

import easygui
print easygui.fileopenbox()

To install:

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

Demo:

import easygui
easygui.egdemo()
J.F. Sebastian
+3  A: 

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

from tkinter.filedialog import askopenfilename
filename = askopenfilename()
stefano palazzo