如果您正在编写一个基于文档的应用程序,这很简单:文档控制器接收到一条openDocumentWithContentsOfURL:display:error:消息(对于pre-Tiger系统,openDocumentWithContentsOfFile:display:),并将handle this accordingly。在
def doOpenFile(*args):
for fn in args:
flist.open(fn)
# The command below is a hook in aquatk that is called whenever the app
# receives a file open event. The callback can have multiple arguments,
# one for every file that should be opened.
root.createcommand("::tk::mac::OpenDocument", doOpenFile)
一般来说,这些都是通过苹果事件来处理的。特别是,您的应用程序将收到一个打开文档事件。如何处理它取决于您编写的应用程序的类型。在
如果您正在编写一个基于文档的应用程序,这很简单:文档控制器接收到一条
openDocumentWithContentsOfURL:display:error:
消息(对于pre-Tiger系统,openDocumentWithContentsOfFile:display:
),并将handle this accordingly。在对于不基于文档的Cocoa应用程序,将向应用程序委托发送一条},按顺序排列)。在
application:openFiles:
消息。如果委托没有对此做出响应,它将尝试发送其他消息,直到代理响应一条消息(openTempFile:
,openFiles:
,和{Here's the documentation用于在Cocoa中处理打开的苹果事件。在
对于Carbon应用程序,我真的记不起细节了(自从我写了Carbon代码以来已经有一段时间了),但是如果我没记错的话,您应该为带有
AEInstallEventHandler()
的kAEOpenDocuments
事件安装一个Apple事件处理程序。有关详细信息,请参见the documentation。在看起来您需要一个GUI工具箱来完成这一点,idlelib/macosxSupport.py中有一个示例
Qt也有support。在
相关问题 更多 >
编程相关推荐