[Tkinter-discuss] Display Files in Directory

Prahlad Yeri prahladyeri at yahoo.com
Mon Sep 11 23:51:58 EDT 2017


On Mon, 11 Sep 2017 10:44:07 -0500
Austin Redding <austinmredding at gmail.com> wrote:

> I'm attempting to use 'askdirectory' in order to populate a widget
> with the relevant files in the user selected directory.  However,
> when using 'askdirectory' the user isn't able to see the files inside
> the directory, unlike 'askopenfilename' which displays all the files.

It appears from your question that your objective is to create a way
for the user to be able to select multiple file(s) through a single
dialog that shows all files/folders, so that they don't have to
select each file/folder individually. Is this requirement correct? If
so, then you can use the filedialog.askopenfilenames (with an s in the
end) that is able to do exactly this:

from tkinter import filedialog

files = filedialog.askopenfilenames(parent=self.master,title='Choose
the Music file(s)', filetypes=(("xml files", "*.xml")))

I'd used this code in one of my projects where the user wanted to
select multiple xml files for processing by using one single browse
button. Hope this helps.

-- 
Regards,
Prahlad


More information about the Tkinter-discuss mailing list