[Pythonmac-SIG] Replacing macfs.StandardGetFile and friends.

Just van Rossum just@letterror.com
Fri, 17 Jan 2003 19:37:05 +0100


Jack Jansen wrote:

> The calls EasyDialogs.AskFileForOpen(), AskFileForSave() and 
> AskFolder() have been implemented in CVS. Please give them a try. 
> They've been tested only very lightly, so I could use a helping hand 
> here with all the options.

AskFileForSave() traces back if called with no arguments:

Traceback (most recent call last):
  File "/Users/just/code/tmp/build/Ask.app/Contents/Resources/Ask.py",
line 3, in ?
    print EasyDialogs.AskFileForSave()
  File "/Users/just/code/python_cvs/Lib/plat-mac/EasyDialogs.py", line
663, in AskFileForSave
    pardir_fsr = Carbon.File.FSRef(fss)
NameError: global name 'fss' is not defined

I think the dialogs should be movable; this should work correctly in an
eventloop-less app as well in a CarbonEvents-based app. (This may be an
incentive for me to convert the IDE to use CarbonEvents...)

> No documentation yet, but the main options are as follows (read the 
> source for EasyDialogs.py and Nav.c for details):
> - wanted: you can pass a type here telling what you want back. FSSpec, 
> FSRef, str or unicode (or subtypes thereof!) are acceptable.
> - message: the prompt (only ascii, for now)
> - savedFileName: the default output filename (only ascii, for now)
> - typeList: a list or tuple of 4-char filetype codes (or the
Res.Handle 
> data structure Nav really uses)
> - defaultLocation: which folder to show the user first (FSSpec, FSRef, 
> pathname and AE are acceptable)
> 
> The return value is of type "wanted" or None if the user cancelled.
> 
> If someone can come up with an example for a filterProc use that would 
> be nice.

Traceback (most recent call last):
  File "/Users/just/code/tmp/build/Ask.app/Contents/Resources/Ask.py",
line 7, in ?
    print EasyDialogs.AskFileForSave(message="Hello", filterProc=proc)
  File "/Users/just/code/python_cvs/Lib/plat-mac/EasyDialogs.py", line
651, in AskFileForSave
    raise Nav.error, arg
Nav.error: Unknown DialogOption key: filterProc

Which leads me to the next point: I think these functions should have
the possible keyword args explicitly set. That way you can more or less
figur it out by merely reading EasyDialogs.py...

Just