[Tutor] filtering listed directories

Laura Creighton lac at openend.se
Sat Aug 22 12:43:37 CEST 2015


In a message of Sat, 22 Aug 2015 12:20:31 +1000, Chris Roy-Smith writes:
>Hi,
>environment: Python 2.7, Ubuntu 12.4 Linux
>
>I am trying to get the list of directories shown by 
>tkFileDialog.askdirectory to not show hidden files (starting with .)
>
>this code results in lots of hidden directories listed in the interface 
>making things harder than they need to be for the user.
>
>#! /usr/bin/python
>import Tkinter, tkFileDialog
>root = Tkinter.Tk()
>root.withdraw()
>
>dirname = 
>tkFileDialog.askdirectory(parent=root,initialdir="/home/chris/",title='Pick 
>a directory')
>
>How can I filter out these hidden directories?
>Help(tkFileDialog) doesn't help me as it just shows **options, but 
>doesn't show what these options might be.

The options are listed here:

http://effbot.org/tkinterbook/tkinter-file-dialogs.htm
or
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/tkFileDialog.html

Unfortunately, they do not help.  There is all sorts of help for
'only show things that match a certain pattern' but not for
'only show things that do not match a certain pattern'.
(Or maybe my pattern-making skill is at fault, but I don't
think so.)

tix (tkinter extensions) https://wiki.python.org/moin/Tix
have some more file dialogs, so maybe there is joy there.

This seems utterly crazy to me -- you surely aren't the first person
who wanted to exclude certain directories in a file dialog.

I will look more later this afternoon in my old tkinter files.  I
must have wanted to do this at one point, mustn't I?

puzzled,
Laura




More information about the Tutor mailing list