[python-win32] EasyDialogs - typeList

Tim Roberts timr at probo.com
Wed Dec 6 21:07:13 CET 2006


Axiom X11 wrote:
> I am trying to write a dialog the opens a video file.
> ...
> What I want to do is have it show
>
> Video Files (*.avi;*.mpg;*.mpeg)
>
> This idea is hinted at on this page:
> http://www.averdevelopment.com/python/EasyDialogs.html
> But the example doesn't seem to work (or perhaps I don't understand
> how to use it)
>
> When I tried it like this:
>
> file = EasyDialogs.AskFileForOpen(defaultLocation="c:\\",
> typeList=(('C Files (*.c, *.h)', '*.c;*.h')))

Ah, you got trapped by perhaps the greatest Python syntax trap.  What
you have given to typeList is NOT a tuple of tuples: the outer set of
parentheses are interpreted as grouping parens and are discarded.  You
have it a list with two entries, which is what it displayed.  Try this:

     file = EasyDialogs.AskForFileOpen(
        defaultLocation="c:\\",
        typeList=( ('Video Files (*.avi,*.mpg,*.mpeg)',
'*.avi;*.mpg;*.mpeg'), )
    )

Notice the extra comma inside the outer parens.  That's the key.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list