Re: Looking for example demonstrating calling python from Objective-C

Ronald Oussoren via Pyobjc-dev <[email protected]> Wed, 5 Dec 2018 13:17:13 +0100
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
--===============0831128110258618287==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_D98F3608-9641-4312-988D-5E88E1850164"


--Apple-Mail=_D98F3608-9641-4312-988D-5E88E1850164
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

The closest thing to documentation about this is: =
https://pyobjc.readthedocs.io/en/latest/tutorials/embedded.html =
<https://pyobjc.readthedocs.io/en/latest/tutorials/embedded.html>, but =
that document is very old and is probably out of date.  The reason for =
the lack of documentation is that almost all users for PyObjC use it to =
write Python code that use the Apple ObjC frameworks.=20

In the end the basic idea is:

* Create a Python subclass of NSObject with methods that you want to =
call from from ObjC (make sure you use the right naming convention for =
those methods)
* In ObjC create an @interface definition with the methods you want to =
call in ObjC
* Create the Python object in Python and pass it to the ObjC code in =
some way
* Call methods as normal in ObjC

Ronald

P.S. Sorry about the late response, I=E2=80=99ve been traveling and =
couldn=E2=80=99t approve your message to the list earlier.
=20
> On 19 Nov 2018, at 17:29, Dmitry Wolf <[email protected]> wrote:
>=20
> I'm trying to figure out how to call python from cocoa/objective-c =
code, but haven't found any example code that actually works. There seem =
to be all sorts of examples of pure python calling into frameworks and =
objective-c code, but nothing showing how to set up calls from a =
standard objective-c app into python.
>=20
> Actually I just copy pasted this question from 2006 thread =
https://sourceforge.net/p/pyobjc/mailman/message/11676132/ =
<https://sourceforge.net/p/pyobjc/mailman/message/11676132/>
> Because I have exactly this question :D
> _______________________________________________
> Pyobjc-dev mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev


--Apple-Mail=_D98F3608-9641-4312-988D-5E88E1850164
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D"">The =
closest thing to documentation about this is:&nbsp;<a =
href=3D"https://pyobjc.readthedocs.io/en/latest/tutorials/embedded.html" =
class=3D"">https://pyobjc.readthedocs.io/en/latest/tutorials/embedded.html=
</a>, but that document is very old and is probably out of date. =
&nbsp;The reason for the lack of documentation is that almost all users =
for PyObjC use it to write Python code that use the Apple ObjC =
frameworks.&nbsp;<div class=3D""><br class=3D""></div><div class=3D"">In =
the end the basic idea is:</div><div class=3D""><br class=3D""></div><div =
class=3D"">* Create a Python subclass of NSObject with methods that you =
want to call from from ObjC (make sure you use the right naming =
convention for those methods)</div><div class=3D"">* In ObjC create an =
@interface definition with the methods you want to call in =
ObjC</div><div class=3D"">* Create the Python object in Python and pass =
it to the ObjC code in some way</div><div class=3D"">* Call methods as =
normal in ObjC<div class=3D""><br class=3D""></div><div =
class=3D"">Ronald</div><div class=3D""><br class=3D""></div><div =
class=3D""><div>P.S. Sorry about the late response, I=E2=80=99ve been =
traveling and couldn=E2=80=99t approve your message to the list =
earlier.</div><div>&nbsp;<br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D"">On 19 Nov 2018, at 17:29, Dmitry Wolf &lt;<a =
href=3D"mailto:[email protected]" class=3D"">[email protected]</a>&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div =
dir=3D"ltr" class=3D""><div dir=3D"ltr" class=3D"">I'm trying to figure =
out how to call python from cocoa/objective-c code, but haven't found =
any example code that actually works. There seem to be all sorts of =
examples of pure python calling into frameworks and objective-c code, =
but nothing showing how to set up calls from a standard objective-c app =
into python.<div class=3D""><br class=3D""></div><div class=3D"">Actually =
I just copy pasted this question from 2006 thread&nbsp;<a =
href=3D"https://sourceforge.net/p/pyobjc/mailman/message/11676132/" =
class=3D"">https://sourceforge.net/p/pyobjc/mailman/message/11676132/</a><=
/div><div class=3D"">Because I have exactly this question =
:D</div></div></div>
_______________________________________________<br class=3D"">Pyobjc-dev =
mailing list<br class=3D""><a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a><br =
class=3D"">https://lists.sourceforge.net/lists/listinfo/pyobjc-dev<br =
class=3D""></div></blockquote></div><br =
class=3D""></div></div></body></html>=

--Apple-Mail=_D98F3608-9641-4312-988D-5E88E1850164--


--===============0831128110258618287==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============0831128110258618287==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Pyobjc-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev

--===============0831128110258618287==--