[Tkinter-discuss] Tkinter-discuss Digest, Vol 136, Issue 3

Daniel Graham, Ph.D. daniel.graham at duke.edu
Sun Aug 23 15:11:03 CEST 2015


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-request at python.org<mailto:tkinter-discuss-request at python.org> wrote:

Send Tkinter-discuss mailing list submissions to
tkinter-discuss at python.org<mailto:tkinter-discuss at 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-request at python.org

You can reach the person managing the list at
tkinter-discuss-owner at 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 <lac at openend.se>
To: tkinter-discuss at python.org
Subject: [Tkinter-discuss] tkinter file dialog pattern matching
Message-ID: <201508221103.t7MB3kdx010426 at 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 <pawel at mosakowski.net>
To: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] tkinter file dialog pattern matching
Message-ID: <20150822210424.321b826f at 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 <lac at 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 at python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss



------------------------------

Message: 3
Date: Sat, 22 Aug 2015 22:17:11 +0200
From: Laura Creighton <lac at openend.se>
To: Pawel Mosakowski <pawel at mosakowski.net>
Cc: tkinter-discuss at python.org, lac at openend.se
Subject: Re: [Tkinter-discuss] tkinter file dialog pattern matching
Message-ID: <201508222017.t7MKHBac022500 at 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 <Cameron at phaseit.net>
To: Laura Creighton <lac at openend.se>
Cc: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] tkinter file dialog pattern matching
Message-ID: <20150822225102.GA12242 at 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 at python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


------------------------------

End of Tkinter-discuss Digest, Vol 136, Issue 3
***********************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20150823/999b7a51/attachment-0001.html>


More information about the Tkinter-discuss mailing list