[Tutor] [Tkinter-discuss] tkinter file dialog pattern matching (fwd)

Alan Gauld alan.gauld at btinternet.com
Sun Aug 23 18:26:04 CEST 2015


On 23/08/15 16:11, Laura Creighton wrote:
> But, aha, it works for Python3.5

I only trued it on 2.7.
I'll have a go on 3.4...

> I wrote this minimal program, to see what needed doing to solve the OP's
> problem, and, surprise, it solves it right out of the box.


> from tkinter import *
> import tkinter.tix as tix

I believe tix is a complete superset of tkinter so
you only need the tix import.

> root = tix.Tk()
>
> def print_selected(args):
>      print('selected dir:', args)
>
> def pathSelect():
>      d = tix.ExFileSelectDialog(master=root, command=print_selected)
>          d.popup()

The dircmd option should work too.
Although you might need to pull out the subwidget first

sub = d.subwidget('fsbox')
sub['dircmd'] = lambda d,f,h: glob.glob(pattern)


-- 
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