[Tutor] filtering listed directories

Alan Gauld alan.gauld at btinternet.com
Sun Aug 23 16:26:29 CEST 2015


On 23/08/15 09:31, Chris Roy-Smith wrote:

>>>> There is a FileSelectDialog in Tix that has a dircmd option
>>>> according to the Tix documentation.

>>>> There is also allegedly a 'hidden' check-box subwidget
>>>> that controls whether hidden files are shown. Again I
>>>> couldn't find how to access this.

This combo  looks like the best solution if I can find
how to make it work. Its the logical solution and I'm
astounded that none of the common GUIs seem to offer it.
(Although I've been building GUIS for over 20 years and
never needed it until now! So maybe not so surprising).

I'm hoping to buy out some time over the next couple
of days to seriously explore the Tix dialogs.

>> there only minimal pattern support matching, but there is no way to
>> subclass the thing and feed it your own list of file and directory

This is true and it is because Tkinter has used the underlying GUI 
toolkit rather than building open/save from scratch. (Native Tk
offers no standard dialogs for file operations!)

However there is another option in the shape of the Dialog module
which is designed to allow you to easily build a custom dialog
of your own design. This could be done using the Tix tree view
widget for example and you could then build in a file filter
operation. (A search may even reveal that somebody has done
this already... I think that's what the Tk code Laura posted
was doing))

> I can only assume that windows users don't get this problem.

Its got nothing to do with the OS, the same limitations apply
in all cases. They have taken the minimum subset of options
when they built the common dialogs. But the standard Windows
dialog doesn't offer exclusion options either, so even if
they had offered platform specific hooks, it would not have
helped on Windows. wxPython does the same, so has the same
limitations.

> Do any of the other graphical packages avoid this problem?

The GTk dialogs  on my Linux box have slightly more
sophisticated options so I'd guess that PyGTK at least
will offer more in the API (But even they don't appear
to have filter out capability). PyQt/SIDE probably
offers more too but I don't know very much about Qt.

One possibility on Windows is that the list of folders shown
is con trolled by the users registry settings in the file
explorer. You can choose to hide "system files" in the
Explorer view and that sets a registry flag. I haven't
checked but its possible that the Windows open/save
dialogs respect that setting. But that's just a guess!


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list