I use fnmatch: for path, dirs, files in os.walk(root): # exclude dirs dirs[:] = [os.path.join(path, d) for d in dirs if not fnmatch.fnmatch(d, exclude)] # exclude files files = [os.path.join(path, f) for f in files if not fnmatch.fnmatch(f, exclude)]
where exclude=r’.*’ -Dan On Aug 23, 2015, at 6:00 AM, tkinter-discuss-requ...@python.org<mailto:tkinter-discuss-requ...@python.org> wrote: Send Tkinter-discuss mailing list submissions to tkinter-discuss@python.org<mailto:tkinter-discuss@python.org> To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/tkinter-discuss or, via email, send a message with subject or body 'help' to tkinter-discuss-requ...@python.org You can reach the person managing the list at tkinter-discuss-ow...@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Tkinter-discuss digest..." Today's Topics: 1. tkinter file dialog pattern matching (Laura Creighton) 2. Re: tkinter file dialog pattern matching (Pawel Mosakowski) 3. Re: tkinter file dialog pattern matching (Laura Creighton) 4. Re: tkinter file dialog pattern matching (Cameron Laird) ---------------------------------------------------------------------- Message: 1 Date: Sat, 22 Aug 2015 13:03:46 +0200 From: Laura Creighton <l...@openend.se> To: tkinter-discuss@python.org Subject: [Tkinter-discuss] tkinter file dialog pattern matching Message-ID: <201508221103.t7mb3kdx010...@fido.openend.se> Content-Type: text/plain; charset="us-ascii" Somebody on the tutor mailing list wants to match "all files and direcories in this directory that do not start with a ." The filetypes option seems only to want patterns to match, not patterns to exclude. Is my pattern matching magic just off, or is there no way to exclude things in a tkFileDialog? puzzled, Laura ------------------------------ Message: 2 Date: Sat, 22 Aug 2015 21:04:24 +0100 From: Pawel Mosakowski <pa...@mosakowski.net> To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] tkinter file dialog pattern matching Message-ID: <20150822210424.321b826f@lenny> Content-Type: text/plain; charset=US-ASCII Hi, I've found this little gem in the Tk docs https://www.tcl.tk/man/tcl8.4/TkCmd/getOpenFile.htm#M13 From what I see "file patterns" in the file dialog are not "regex patterns" and do not support special characters. Only things that work are: 1) * - any extension 2) "" - files without extension 3) literal extension without wildcard chars Unfortunately it looks like there is no simple way to filter out hidden files. Check out this answer https://mail.python.org/pipermail//tutor/2011-November/086483.html Regards, Pawel Mosakowski On Sat, 22 Aug 2015 13:03:46 +0200 Laura Creighton <l...@openend.se> wrote: Somebody on the tutor mailing list wants to match "all files and direcories in this directory that do not start with a ." The filetypes option seems only to want patterns to match, not patterns to exclude. Is my pattern matching magic just off, or is there no way to exclude things in a tkFileDialog? puzzled, Laura _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss ------------------------------ Message: 3 Date: Sat, 22 Aug 2015 22:17:11 +0200 From: Laura Creighton <l...@openend.se> To: Pawel Mosakowski <pa...@mosakowski.net> Cc: tkinter-discuss@python.org, l...@openend.se Subject: Re: [Tkinter-discuss] tkinter file dialog pattern matching Message-ID: <201508222017.t7mkhbac022...@fido.openend.se> Content-Type: text/plain; charset="us-ascii" In a message of Sat, 22 Aug 2015 21:04:24 +0100, Pawel Mosakowski writes: Hi, I've found this little gem in the Tk docs https://www.tcl.tk/man/tcl8.4/TkCmd/getOpenFile.htm#M13 From what I see "file patterns" in the file dialog are not "regex patterns" and do not support special characters. Only things that work are: 1) * - any extension 2) "" - files without extension 3) literal extension without wildcard chars Unfortunately it looks like there is no simple way to filter out hidden files. Check out this answer https://mail.python.org/pipermail//tutor/2011-November/086483.html Regards, Pawel Mosakowski Thank you. Looks like it will be necessary to construct a new widget. I'm surprised ... Laura ------------------------------ Message: 4 Date: Sat, 22 Aug 2015 22:51:02 +0000 From: Cameron Laird <came...@phaseit.net> To: Laura Creighton <l...@openend.se> Cc: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] tkinter file dialog pattern matching Message-ID: <20150822225102.ga12...@lairds.us> Content-Type: text/plain; charset=us-ascii On Sat, Aug 22, 2015 at 10:17:11PM +0200, Laura Creighton wrote: In a message of Sat, 22 Aug 2015 21:04:24 +0100, Pawel Mosakowski writes: Hi, I've found this little gem in the Tk docs https://www.tcl.tk/man/tcl8.4/TkCmd/getOpenFile.htm#M13 From what I see "file patterns" in the file dialog are not "regex patterns" and do not support special characters. Only things that work are: 1) * - any extension 2) "" - files without extension 3) literal extension without wildcard chars Unfortunately it looks like there is no simple way to filter out hidden files. Check out this answer https://mail.python.org/pipermail//tutor/2011-November/086483.html Regards, Pawel Mosakowski Thank you. Looks like it will be necessary to construct a new widget. I'm surprised ... . . . More than I. I can understand your disappointment that file-dialogue "file patterns" have such a rudimentary syntax; I speculate with considerable confidence that the authors acted with sh as the model most in their mind. You're quite right, Laura, that the elements are at hand to allow you to construct your own variant. If the history of getOpenFile truly interests you, act quickly: while we can get to the authors now, it won't be many cycles more before their memories and records senesce irretrievably. ------------------------------ Subject: Digest Footer _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss ------------------------------ End of Tkinter-discuss Digest, Vol 136, Issue 3 ***********************************************
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss