osx - How to accept "open document" events in py2app based Python app when the app is already running? -
i've been building 64 bit python 3.4.2 app on os x 10.10, bundle mac app using py2app 0.9. have adapted app's info.plist file, os x knows files file name suffix can opened app.
when user double-clicks file file name suffix in finder, opens app , sends name of double-clicked file argument app.
if app running, though, , double-click second file matching file name suffix, file name doesn't seem handed on app.
and try implement: no matter if app running, if double-click matching file in finder, should opened in app.
i have seen py2app creates file contents/resources/boot.py, seems catch odoc apple event sent finder, , sends python app.
i added logging boot.py file , saw boot.py doesn't seem invoked when py2app bundled python app running , double-click file in finder.
any input appreciated.
thanks lot in advance,
andré
i learned, tk on mac can process appleevents, e.g. opening documents.
there's example @ code.activestate.com/lists/pythonmac-sig/23079 , mac specific tk functions listed @ tcl.tk/man/tcl/tkcmd/tk_mac.htm. add like
tk.createcommand("::tk::mac::opendocument", doopenfile)
to tk event loop, doopenfile
needs point function this:
def doopenfile(*args): f in args:
this works in python 2.7 , python 3.4.2 (haven't tested other versions).
Comments
Post a Comment