[python-win32] EasyDialogs - how to set initial path

John Machin sjmachin at lexicon.net
Mon Jul 3 11:20:00 CEST 2006


On 30/06/2005 5:43 PM, Radovan Grznarik wrote:
> Hi,
> 
> I am using EasyDialogs (AskFileForOpen) and I am not able to set the
> initial open path. I found in Python help that it should be 3rd
> parameter,

I doubt it. The Python *documentation*, whose first two lines ("2.7 
EasyDialogs -- Basic Macintosh dialogs", "Availability: Macintosh.) are 
easily ignored, does contain this:

AskFileForOpen( [message] [, typeList] [, defaultLocation] [, 
defaultOptionFlags] etc etc.

But you are running on Windows, and to get as far as you did, you must 
have downloaded Jimmy Retzlaff's 3rd party not quite-compatible subset 
EasyDialogs module.

Then if you use the Python *help*, you get:

C:\junk>python
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
|>> import EasyDialogs
|>> EasyDialogs.__file__
'c:\\python24\\lib\\site-packages\\EasyDialogs\\__init__.pyc'
 >>> help(EasyDialogs.AskFileForOpen)
Help on function AskFileForOpen in module EasyDialogs:

AskFileForOpen(message=None, typeList=None, version=None, 
defaultLocation=None,
dialogOptionFlags=None, location=None, clientName=None,
[snip]


  then I tried this
> 
> filename = EasyDialogs.AskFileForOpen("title","*.*","d:\\")
> 
> but it does not work, and opens dialog in actual directory of running script.

If it's any consolation, you're not the first to get trapped like this :-)

> 
> os.chdir("d:\\") before AskFileForOpen also does not work.
> 

Here's a handy tip: when a function has keyword arguments, use the 
keywords -- not only does it save you counting args, it helps document 
your code.

Here's a (slightly edited) example from one of my scripts:
     import EasyDialogs
     infname = EasyDialogs.AskFileForOpen(
         windowTitle='Fu or Bar file from XYZ',
         typeList=[
             ('All files (*.*)', '*.*'),
             ],
         defaultLocation=r'G:\XYZfiles\FuBar',
         # message='... a message',
         )

Cheers,
John



More information about the Python-win32 mailing list