mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Created Finder 7.0 AE interface and a test program that uses the
finder to launch an application.
This commit is contained in:
parent
6244867e56
commit
35bfd3f9d7
2 changed files with 343 additions and 0 deletions
33
Mac/Lib/test/testfinderopen.py
Normal file
33
Mac/Lib/test/testfinderopen.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
"""Make the finder open an application, file or folder"""
|
||||
|
||||
import Finder_7_0_Suite
|
||||
import aetools
|
||||
import MacOS
|
||||
import sys
|
||||
import macfs
|
||||
|
||||
SIGNATURE='MACS'
|
||||
|
||||
class Finder(aetools.TalkTo, Finder_7_0_Suite.Finder_7_0_Suite):
|
||||
pass
|
||||
|
||||
def open_in_finder(file):
|
||||
"""Open a file thru the finder. Specify file by name or fsspec"""
|
||||
finder = Finder(SIGNATURE)
|
||||
fss = macfs.FSSpec(file)
|
||||
vRefNum, parID, name = fss.as_tuple()
|
||||
dir_fss = macfs.FSSpec((vRefNum, parID, ''))
|
||||
file_alias = fss.NewAlias()
|
||||
dir_alias = dir_fss.NewAlias()
|
||||
return finder.open(file_alias, items=[file_alias])
|
||||
|
||||
def main():
|
||||
fss, ok = macfs.PromptGetFile('File to launch:')
|
||||
if not ok: sys.exit(0)
|
||||
result = open_in_finder(fss)
|
||||
if result:
|
||||
print 'Result: ', result
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue