[Tutor] Python gui for file input
Alan Gauld
alan.gauld at btinternet.com
Fri Jan 5 21:02:20 CET 2007
"Mike Ellis" <maellis002 at yahoo.com> wrote in
> I am looking to create a simple gui interface to a small script.
> The script requires the user to input a directory.
You don't need to write an interface just use the standard
one. Of course if you want to display the result/output in
a GUI then you neeed to do some work. But if you are
happy with a console interace, or a silent application,
then its just a case of using the common dialogs:
>>> import Tkinter as tk>>> import tkFileDialog as fd>>> t =
>>> tk.Tk()>>> t.withdraw() # hides the Tk root window''>>> d =
>>> fd.askdirectory() # display the dir dialog>>> print
>>> dD:/Development>>> dir(fd)['Dialog', 'Directory', 'Open',
>>> 'SaveAs', '_Dialog', '__builtins__', '__doc__','__file__',
>>> '__name__', 'askdirectory', 'askopenfile', 'askopenfilename',
>>> 'askoenfilenames', 'askopenfiles', 'asksaveasfile',
>>> 'asksaveasfilename']>>>As you see there are a number of other
>>> dialogs too. Try googling on their names to find example usage. I
>>> don't know why this isn't documented in the standard library
>>> docs!HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list