1 Star 1 Fork 0

三字经 / blockpy

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
Notice: Creating folder will generate an empty file .keep, because not support in Git



BlockPy is a web-based Python environment that lets you work with blocks, text, or both. Designed for Data Science and equipped with powerful tools like the State Explorer and Guided Feedback, the goal of BlockPy is to let you solve authentic, real-world problems.

The goal of BlockPy is to give you a gentle introduction to Python but eventually mature you into a more serious programming environment (such as Spyder or PyCharm). Long-term, we may support some game/animation design stuff that Scratch/Snap does, but that's not the real goal.

The BlockPy project is aimed at solving some hard technical problems: having a block-based environment for a dynamic language can be tricky - are a given pair of square brackets representing list indexing or dictionary indexing? Our goal is to use advanced program analysis techniques to provide excellent support to learners.


The core architecture of BlockPy is a synthesis of:

  • Blockly: a visual library for manipulating a block canvas that can generate equivalent textual code in a variety of languages
  • Skulpt: an in-browser Python-to-JavaScript compiler/intepreter, that aims to emulate the full language with precision if not speed.

By combining these two technologies, we end up with a powerful system for writing Python code quickly. Everything is meant to run locally in the client, so there's no complexity of sandboxing students' code on the server.

The major innovations are:

  • PythonToBlocks: by parsing the AST generated by Skulpt, we can build equivalent Blockly code, effectively allowing round-trips between text and blocks.
  • CORGIS Datsets: new blocks access real-world datasets (although currently these are only cached versions, for performance reasons).
  • Interactive Guided Problems: Problem text is given to students, along with teacher provided code that can do analysis on the students' code and make suggestions (e.g., observing that they haven't printed anything yet).
  • Data Explorer: The data explorer allows users to walk through their code.


First, setup a root directory for this project. This directory should look something like this:

        ...contents of blockly
        ...contents of blockpy
        ...contents of closure library
        ...contents of skulpt

The respective commands to create these folders should be something along the lines of (note that some of these clones can take a while):

> git clone https://github.com/RealTimeWeb/blockly.git
> git clone https://github.com/RealTimeWeb/blockpy.git
> wget https://github.com/google/closure-library/zipball/master -O closure.zip
> unzip closure.zip
> git clone https://github.com/RealTimeWeb/skulpt.git

You'll need to build Skulpt and Blockly. Both of these depend on the Closure Compiler, so you'll need to put that in the empty closure-library folder.

CD into your root directory

> cd root/

Next, you'll need to build Blockly. The en.js file doesn't quite build correctly so you want to copy it out and paste it back in. It should be something along the lines of:

> cp blockly/msg/js/en.js en.js
> cd blockly
> python build.py
> cd ..
> mv -force en.js blockly/msg/js/en.js

Note that blockly builds in python2

And then you'll build Skulpt:

> cd skulpt
> python skulpt.py dist
> cd ..

Note: You may have to create a "dist" folder in the skulpt directory Note: skulpt builds in python3

If you are on windows, you may encounter the message "No gzip executable", you can safely ignore this.

And now you should be able to try out the example file!

> start blockpy_new.html

The server has its own requirements.txt and uses a python manage.py runserver

If you make edits to either Blockly or Skulpt, you'll need to rerun their build commands. Simiarly, if you edit src/interface.html than you'll need to rebuild it:

> python build.py

Otherwise, you should be able to edit the src/*.js files freely. To get a sense of the dependencies, check out the blockpy_new.html file and then the src/main.js file. These should be good starting points.

Comments ( 0 )

Sign in for post a comment


No description spread retract


No release




load more
can not load any more