Microsoft MakeCode

Python

I see that the git mainline has support for Python. I would like to incorporate python into pxt-sample. I tried the obvious of adding the python entries found in pxtarget.json from pxt-adafruit to pxt-sample. No luck. Where is the documentation on adding python to pxt or what am I missing in moving what works in pxt-adafruit into pxt-sample?

Oh, it looks like the package.json in the pxt-sample repo is pretty out of date! You’ll want the dependencies and devDependencies in that file to look like this:

"devDependencies": {
    "typescript": "^3.7.5",
    "semantic-ui-less": "2.2.14",
    "@types/bluebird": "2.0.33",
    "@types/jquery": "3.3.29",
    "@types/marked": "0.3.0",
    "@types/node": "8.0.53"
},
"dependencies": {
    "pxt-core": "6.0.1"
}

Specifically, you should update the versions for pxt-core, typescript, and @types/jquery. (You can also use ^6.1.22 for pxt-core, which is the latest version with some extra features and fixes.) You may also need to run pxt buildcss --force to update all the CSS after you run npm install again.

Hope that helps!

what you have below plus

diff --git a/pxtarget.json b/pxtarget.json
index 1116e06..e950b06 100644
--- a/pxtarget.json
+++ b/pxtarget.json
@@ -42,7 +42,7 @@
 "monacoToolbox": true,
 "invertedMenu": true,
 "showHomeScreen": true,
- "homeScreenHero": "./static/hero.png",
+ "homeScreenHero": "./static/hero.png",
 "blocklyOptions": {
 "grid": {
 "spacing": 45,
@@ -51,6 +51,8 @@
 "snap": true
 }
 },
+ "python": true,
+ "pythonToolbox": true,
 "simAnimationEnter": "fly right in",
 "simAnimationExit": "fly right out",
 “scriptManager": true,

Gives me python blocks.

Thank you so much.

1 Like