###################################################################### # Default terminology tables for converting between human-readable identifiers and Apple event codes; used by all apps. # Includes default entries for Required Suite, get/set and miscellaneous other commands; application may override some or all of these definitions. # Type tables; used to translate constants # e.g. k.document <-> AEType('docu') # e.g. k.ask <-> AEEnum('ask ') _defaulttypebyname = {} # used to encode class and enumerator keywords _defaulttypebycode = { } # used to decode class (typeType) and enumerator (typeEnum) descriptors _defaulttypecodebyname = {} # used to check for name collisions for _, enumerators in defaultterminology.enumerations: for name, code in enumerators: _defaulttypebyname[name] = AEEnum(code) _defaulttypebycode[code] = Keyword(name) _defaulttypecodebyname[name] = code for defs in [defaultterminology.types, defaultterminology.properties]: for name, code in defs: _defaulttypebyname[name] = AEType(code) _defaulttypebycode[code] = Keyword(name) _defaulttypecodebyname[name] = code # Reference tables; used to translate references and commands # e.g. app(...).documents.text <-> app.elements('docu').property('ctxt') # e.g. app(...).quit(saving=k.ask) <-> Application(...).event('aevtquit', {'savo': AEEnum('ask ')}) _defaultreferencebycode = {} # used to decode property and element specifiers _defaultreferencebyname = { } # used to encode property and element specifiers and Apple events
###################################################################### # Default terminology tables for converting between human-readable identifiers and Apple event codes; used by all apps. # Includes default entries for Required Suite, get/set and miscellaneous other commands; application may override some or all of these definitions. # Type tables; used to translate constants # e.g. k.document <-> AEType('docu') # e.g. k.ask <-> AEEnum('ask ') _typebyname = {} # used to encode class and enumerator keywords _typebycode = { } # used to decode class (typeType) and enumerator (typeEnum) descriptors for _, enumerators in appscripttypedefs.enumerations: for name, code in enumerators: _typebyname[name] = AEEnum(code) _typebycode[code] = Keyword(name) for defs in [ appscripttypedefs.alltypes, appscripttypedefs.commontypes, appscripttypedefs.properties ]: for name, code in defs: _typebyname[name] = AEType(code) _typebycode[code] = Keyword(name) # Reference tables; used to translate references and commands # e.g. app(...).documents.text <-> app.elements('docu').property('ctxt') # e.g. app(...).quit(saving=k.ask) <-> Application(...).event('aevtquit', {'savo': AEEnum('ask ')}) _defaultcommands = { # 'run', 'open', 'print' and 'quit' are Required Suite commands so should always be available.
osax('sysottos', _params({'----': text}, ('DISP', display), ('VOIC', voice), ('wfsp', waiting), ('stof', outputfile)), target=app) def beep(times=None): """Beep 1 or more times times : int -- number of times to beep """ osax('sysobeep', _params({}, ('----', times))) ## kStop = AEEnum('\x00\x00\x00\x00') kNote = AEEnum('\x00\x00\x00\x01') kCaution = AEEnum('\x00\x00\x00\x02') def displaydialog(text, buttons=None, defaultbutton=None, defaultanswer=None, icon=None, timeout=None, app=kCurrentApplication): """Display a dialog box, optionally requesting user input text : str -- the text to display in dialog box buttons : list of str -- a list of up to three button names defaultbutton : int | str -- the name or number of the default button