Pass variables from Python to JS

85 views
Skip to first unread message

Adriano Deganis

unread,
Mar 27, 2015, 6:59:46 PM3/27/15
to sku...@googlegroups.com
Hi everyone...does anybody know how to pass variables from Python code to JS with SKULPT???

Regards

Doug Blank

unread,
Mar 28, 2015, 6:56:53 PM3/28/15
to sku...@googlegroups.com
On Friday, March 27, 2015 at 6:59:46 PM UTC-4, Adriano Deganis wrote:
Hi everyone...does anybody know how to pass variables from Python code to JS with SKULPT???

Regards

Depends on what you mean. If you have already evaluated Python code, such as "x = 42" then you can get access to the value bound to x in Javascript like:

Sk.globals["x"].v

If you want to make a Python value in Javascript and put it in the Python environment, you could:

Sk.globals["new_x"] = new Sk.builtin.nmber(125);

(I've only been working with Skulpt for a short while, so take this advice with a grain of salt.)

Hope that helps,

-Doug
Reply all
Reply to author
Forward
0 new messages