[Python-checkins] python/dist/src/Lib/plat-mac EasyDialogs.py,1.4,1.5
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Tue, 21 Jan 2003 06:38:36 -0800
Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv30579
Modified Files:
EasyDialogs.py
Log Message:
Spell out the arguments to AskFileForOpen and friends, so help() gives useful
help.
Index: EasyDialogs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/EasyDialogs.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** EasyDialogs.py 21 Jan 2003 13:56:34 -0000 1.4
--- EasyDialogs.py 21 Jan 2003 14:38:32 -0000 1.5
***************
*** 5,8 ****
--- 5,12 ----
AskPassword(prompt, default) -- like AskString(), but shows text as bullets.
AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
+ GetArgv(optionlist, commandlist) -- fill a sys.argv-like list using a dialog
+ AskFileForOpen(...) -- Ask the user for an existing file
+ AskFileForSave(...) -- Ask the user for an output file
+ AskFolder(...) -- Ask the user to select a folder
bar = Progress(label, maxvalue) -- Display a progress bar
bar.set(value) -- Set value
***************
*** 32,35 ****
--- 36,43 ----
import os
+ __all__ = ['Message', 'AskString', 'AskPassword', 'AskYesNoCancel',
+ 'GetArgv', 'AskFileForOpen', 'AskFileForSave', 'AskFolder',
+ 'Progress']
+
_initialized = 0
***************
*** 550,596 ****
del d
! def _mktypelist(typelist):
! # Workaround for OSX typeless files:
! if 'TEXT' in typelist and not '\0\0\0\0' in typelist:
! typelist = typelist + ('\0\0\0\0',)
! if not typelist:
! return None
! data = 'Pyth' + struct.pack("hh", 0, len(typelist))
! for type in typelist:
! data = data+type
! return Carbon.Res.Handle(data)
!
! _ALLOWED_KEYS = {
! 'version':1,
! 'defaultLocation':1,
! 'dialogOptionFlags':1,
! 'location':1,
! 'clientName':1,
! 'windowTitle':1,
! 'actionButtonLabel':1,
! 'cancelButtonLabel':1,
! 'savedFileName':1,
! 'message':1,
! 'preferenceKey':1,
! 'popupExtension':1,
! 'eventProc':1,
! 'previewProc':1,
! 'filterProc':1,
! 'typeList':1,
! 'fileType':1,
! 'fileCreator':1,
! # Our extension:
! 'wanted':1,
! 'multiple':1,
! }
!
! def _process_Nav_args(argsargs, allowed, dftflags):
import aepack
import Carbon.AE
import Carbon.File
- args = argsargs.copy()
for k in args.keys():
! if not allowed.has_key(k):
! raise TypeError, "Unknown keyword argument: %s" % repr(k)
# Set some defaults, and modify some arguments
if not args.has_key('dialogOptionFlags'):
--- 558,568 ----
del d
! def _process_Nav_args(dftflags, **args):
import aepack
import Carbon.AE
import Carbon.File
for k in args.keys():
! if args[k] is None:
! del args[k]
# Set some defaults, and modify some arguments
if not args.has_key('dialogOptionFlags'):
***************
*** 619,625 ****
return args, tpwanted
! def AskFileForOpen(**args):
default_flags = 0x56 # Or 0xe4?
! args, tpwanted = _process_Nav_args(args, _ALLOWED_KEYS, default_flags)
try:
rr = Nav.NavChooseFile(args)
--- 591,625 ----
return args, tpwanted
! def AskFileForOpen(
! version=None,
! defaultLocation=None,
! dialogOptionFlags=None,
! location=None,
! clientName=None,
! windowTitle=None,
! actionButtonLabel=None,
! cancelButtonLabel=None,
! message=None,
! preferenceKey=None,
! popupExtension=None,
! eventProc=None,
! previewProc=None,
! filterProc=None,
! typeList=None,
! wanted=None,
! multiple=None):
! """Display a dialog asking the user for a file to open.
!
! wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
! the other arguments can be looked up in Apple's Navigation Services documentation"""
!
default_flags = 0x56 # Or 0xe4?
! args, tpwanted = _process_Nav_args(default_flags, version=version,
! defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
! location=location,clientName=clientName,windowTitle=windowTitle,
! actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
! message=message,preferenceKey=preferenceKey,
! popupExtension=popupExtension,eventProc=eventProc,previewProc=previewProc,
! filterProc=filterProc,typeList=typeList,wanted=wanted,multiple=multiple)
try:
rr = Nav.NavChooseFile(args)
***************
*** 641,647 ****
raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
! def AskFileForSave(**args):
default_flags = 0x07
! args, tpwanted = _process_Nav_args(args, _ALLOWED_KEYS, default_flags)
try:
rr = Nav.NavPutFile(args)
--- 641,676 ----
raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
! def AskFileForSave(
! version=None,
! defaultLocation=None,
! dialogOptionFlags=None,
! location=None,
! clientName=None,
! windowTitle=None,
! actionButtonLabel=None,
! cancelButtonLabel=None,
! savedFileName=None,
! message=None,
! preferenceKey=None,
! popupExtension=None,
! eventProc=None,
! fileType=None,
! fileCreator=None,
! wanted=None,
! multiple=None):
! """Display a dialog asking the user for a filename to save to.
!
! wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
! the other arguments can be looked up in Apple's Navigation Services documentation"""
!
!
default_flags = 0x07
! args, tpwanted = _process_Nav_args(default_flags, version=version,
! defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
! location=location,clientName=clientName,windowTitle=windowTitle,
! actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
! savedFileName=savedFileName,message=message,preferenceKey=preferenceKey,
! popupExtension=popupExtension,fileType=fileType,fileCreator=fileCreator,
! wanted=wanted,multiple=multiple)
try:
rr = Nav.NavPutFile(args)
***************
*** 670,676 ****
raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
! def AskFolder(**args):
default_flags = 0x17
! args, tpwanted = _process_Nav_args(args, _ALLOWED_KEYS, default_flags)
try:
rr = Nav.NavChooseFolder(args)
--- 699,731 ----
raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
! def AskFolder(
! version=None,
! defaultLocation=None,
! dialogOptionFlags=None,
! location=None,
! clientName=None,
! windowTitle=None,
! actionButtonLabel=None,
! cancelButtonLabel=None,
! message=None,
! preferenceKey=None,
! popupExtension=None,
! eventProc=None,
! filterProc=None,
! wanted=None,
! multiple=None):
! """Display a dialog asking the user for select a folder.
!
! wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
! the other arguments can be looked up in Apple's Navigation Services documentation"""
!
default_flags = 0x17
! args, tpwanted = _process_Nav_args(default_flags, version=version,
! defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
! location=location,clientName=clientName,windowTitle=windowTitle,
! actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
! message=message,preferenceKey=preferenceKey,
! popupExtension=popupExtension,eventProc=eventProc,filterProc=filterProc,
! wanted=wanted,multiple=multiple)
try:
rr = Nav.NavChooseFolder(args)