从标准 Cocoa 应用程序运行 python 代码

发布于 2024-07-18 03:38:35 字数 344 浏览 3 评论 0原文

我有一个 XCode 项目构建为 Cocoa 单文档应用程序(它不是 Python-Cocoa 应用程序,这不是我想要的)。

我找到的所有文档都假设我想用 Python 编写的代码创建一个 Cocoa 应用程序,但事实并非如此 - 我想要一个标准的 Cocoa 应用程序,它调用 Python 类中的方法。

我可以使用 PyObjC 从文件运行 python 代码,而不用 main.py 文件替换 Cocoa 标准 main.c 吗?

稍后编辑:我知道 Python.framework 但据我所知,我只能通过环境将参数发送到 PyRun_SimpleFile - 我想直接使用桥与 python 代码交换数据。

I have an XCode project built as a Cocoa single document application (it's not a Python-Cocoa application, that is not what I want).

All the documentation I found assumes I want to create a Cocoa application with code written in Python and this is not the case - I want a standard Cocoa application that calls a method out of a Python class.

Can I use PyObjC to run python code from a file without replacing the Cocoa standard main.c with a main.py file?

Later edit: I am aware of Python.framework but as far as I can tell I can only send parameters to PyRun_SimpleFile through the environment - I'd like to use the bridge directly to exchange data with the python code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文