Tkinter FileDialog

Godson Gera godson.g at gmail.com
Mon May 23 02:32:17 EDT 2011


Hi,

You can try the following

from Tkinter import*
root = Tk()
root.withdraw() #this will hide the main window
import tkFileDialog as tkf
f = tkf.Open().show()

tkFileDialog, requires a main window to be existing before it can show the
file dialog. If there are no main windows then it will create its own.
On Mon, May 23, 2011 at 1:43 AM, Alex van der Spek <zdoor at xs4all.nl> wrote:

> Trying to bring up a simple File or Directory chooser using Tkinter. Right
> now I use pywin32  as Mark Hammond's extensions are somewhat more familiar
> to an (ex)VB programmer who started way back with Fortran.
>
> On Windows Vista with Python 2.7. The examples from Mark Lutz' book
> "Programming Python" do not immediately apply. The book describes Python 3.x
> only.
>
> This is what I do (in IDLE):
>
> import tkFileDialog as tk
> file2open=tk.Open().show()
>
> This works. But it also brings up a persistent Tk window. Killing this
> window forces a restart in IDLE, which is not desirable. There does not
> appear to be a way to multiselect files?
>
> I am probably missing a whole lot. Please point me to a simple example of
> GUI file manipulations. I can save myself with os.path.walk and os.listdir
> but the users I try to serve cannot.
>
> Regards,
> Alex van der Spek
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Thanks & Regards,
Godson Gera
FreeSWITCH & Python Consultant India <http://godson.in/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110523/8cf6faf4/attachment.html>


More information about the Python-list mailing list