From austinmredding at gmail.com Mon Sep 11 11:44:07 2017 From: austinmredding at gmail.com (Austin Redding) Date: Mon, 11 Sep 2017 10:44:07 -0500 Subject: [Tkinter-discuss] Display Files in Directory Message-ID: 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. Is there any fix to allow for the contents of a directory to be displayed (like 'askopenfilename'), but maintain the functionality of 'askdirectory'? I want to use 'askdirectory' because I don't want the user to have to create a new file dialog window every time they want to switch between files located in the same directory. I've dug through the source code, but I can't seem to pinpoint where the decision to display/show files is made depending on the choice of 'askopenfilename', 'askdirectory', etc. Any help or direction would be greatly appreciated. Thanks, Austin -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Sep 11 16:25:42 2017 From: klappnase at web.de (Michael Lange) Date: Mon, 11 Sep 2017 22:25:42 +0200 Subject: [Tkinter-discuss] Display Files in Directory In-Reply-To: References: Message-ID: <20170911222542.4487375d2a0f0b57973e35af@web.de> Hi Austin, On Mon, 11 Sep 2017 10:44:07 -0500 Austin Redding 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. > > Is there any fix to allow for the contents of a directory to be > displayed (like 'askopenfilename'), but maintain the functionality of > 'askdirectory'? I want to use 'askdirectory' because I don't want the > user to have to create a new file dialog window every time they want to > switch between files located in the same directory. > > I've dug through the source code, but I can't seem to pinpoint where the > decision to display/show files is made depending on the choice of > 'askopenfilename', 'askdirectory', etc. Any help or direction would be > greatly appreciated. I don't think this can be done with the plain Tk file dialog. Maybe you could use the tix.ExFileSelectBox or the tix.DirTree instead, or set up something yourself, like checking the contents of the directory returned by askdirectory() and insert the file names into a listbox. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Compassion -- that's the one things no machine ever had. Maybe it's the one thing that keeps men ahead of them. -- McCoy, "The Ultimate Computer", stardate 4731.3 From greg.ewing at canterbury.ac.nz Mon Sep 11 19:35:32 2017 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 12 Sep 2017 11:35:32 +1200 Subject: [Tkinter-discuss] Display Files in Directory In-Reply-To: References: Message-ID: <59B71DC4.90808@canterbury.ac.nz> Austin Redding wrote: > Is there any fix to allow for the contents of a directory to be > displayed (like 'askopenfilename'), but maintain the functionality of > 'askdirectory'? This seems to be platform-dependent. On MacOSX I get a dialog that shows the filenames greyed out. I'm guessing you're using Windows, where the system supplied directory choosing dialog is completely different from the one for choosing filenames and doesn't show files. If that's the case, there's probably nothing you can do about it, because tkinter isn't responsible for the difference. -- Greg From klappnase at web.de Tue Sep 12 03:35:16 2017 From: klappnase at web.de (Michael Lange) Date: Tue, 12 Sep 2017 09:35:16 +0200 Subject: [Tkinter-discuss] Display Files in Directory In-Reply-To: <59B71DC4.90808@canterbury.ac.nz> References: <59B71DC4.90808@canterbury.ac.nz> Message-ID: <20170912093516.87e98366bd4651b40b810cfb@web.de> Hi, On Tue, 12 Sep 2017 11:35:32 +1200 Greg Ewing wrote: > Austin Redding wrote: > > Is there any fix to allow for the contents of a directory to be > > displayed (like 'askopenfilename'), but maintain the functionality of > > 'askdirectory'? > > This seems to be platform-dependent. On MacOSX I get a > dialog that shows the filenames greyed out. > > I'm guessing you're using Windows, where the system > supplied directory choosing dialog is completely > different from the one for choosing filenames and > doesn't show files. If that's the case, there's > probably nothing you can do about it, because > tkinter isn't responsible for the difference. it might be X11 as well, here you still get those Win95-style dialogs provided by Tk (and since Austin said he checked the source code I thought he referred to tkfbox.tcl, but of course I might be wrong there). Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You humans have that emotional need to express gratitude. "You're welcome," I believe, is the correct response. -- Spock, "Bread and Circuses", stardate 4041.2 From prahladyeri at yahoo.com Mon Sep 11 17:10:34 2017 From: prahladyeri at yahoo.com (Prahlad Yeri) Date: Tue, 12 Sep 2017 02:40:34 +0530 Subject: [Tkinter-discuss] Display Files in Directory In-Reply-To: References: Message-ID: <20170912024034.00005ddb@yahoo.com> On Mon, 11 Sep 2017 10:44:07 -0500 Austin Redding 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 From prahladyeri at yahoo.com Mon Sep 11 23:51:58 2017 From: prahladyeri at yahoo.com (Prahlad Yeri) Date: Tue, 12 Sep 2017 09:21:58 +0530 Subject: [Tkinter-discuss] Display Files in Directory In-Reply-To: References: Message-ID: <20170912024034.00005ddb@yahoo.com> On Mon, 11 Sep 2017 10:44:07 -0500 Austin Redding 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