0

I am trying to build a responsive interface using p5.js.

It uses user responses to update pyo4 object variables.

QUESTION

Can I use Python inside p5.js?

QUESTION

If I can't use Python can I use PHP inside p5.js and evoke Python within PHP?


I tried this simple example without luck:

var htmlString="<?php echo $htmlString;?>" 
2
  • Possible duplicate of Running Python scripts from using PHP exec() Commented Mar 17, 2018 at 1:33
  • DyZ, that problem is about python inside php right ? Commented Mar 17, 2018 at 1:39

1 Answer 1

1

Please try to understand the difference between what happens on the server and what happens on the client.

PHP and Python happen on the server, before the page is loaded. You can use this to change what HTML is shown depending on the request, but once the page is loaded you're pretty much done.

P5.js happens on the client, after the page is loaded. You can use this to modify what's already on the page, but you can't directly interact with server code.

Can I use Python inside p5.js?

No.

If I can't use Python can I use PHP inside p5.js and evoke Python within PHP?

No.

What you need to do is create requests from your P5.js code, which can trigger an endpoint on your server. This is called AJAX and there are a ton of resources online about it.

Sign up to request clarification or add additional context in comments.

1 Comment

Really appreciate your guidance, using AJAX . i did able to implement the update function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.