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