Hi there! I am looking for the best strategy to create a channel of communication between a Photoshop UXP plug-in and a Python module. They will be both be running on the same machine. The plug-in needs to send some data to the Python module, the Python module will modify it slightly and send it back.
I would have done this using “child process”, but it has become clear that UXP does not support that functionality yet. What would be the best alternative?
2 Likes
You can use WebSockets for this functionality.
Python would be your web socket server (this is the first link that Google gives me – so no promises on library quality: websockets 10.2 documentation), and then the UXP plugin would establish a connection as a client. Once a connection is established, communication is bi-directional.
The hardest part is establishing the server and communicating the port # to use. Right now you have to rely on the Python side to be running, and once running to write a port # into the plugin’s data folder so that the plugin can pck that port # up and use it. (Or you can use a fixed port # – up to you.)
In the future, if your python side was registered with a URI scheme, UXP could launch it automatically if it wasn’t already running. (This will be in UXP 6.0. If you aren’t in the Ps prerelease - you should join – reach out to @Erin_Finnegan if you need assistance.)
3 Likes
Hi Kerri!
Are there any examples available of how to get a plugin to pick up a (fixed) port number?
I’m working on integrating PS into our facility’s pipeline and the majority of our tooling is Python based so this would be extremely helpful!
Many thanks,
Nikhil
I just realised I’m apparently blind and missed the very obvious example here!