You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is an editor that targets the `MicroPython
7
+
<https://micropython.org>`_ version of the `Python programming language
8
+
<http://python.org/>`_. Code written with this editor is expected to run on the
9
+
`BBC micro:bit device <https://microbit.org>`_.
10
10
11
11
Developer Setup
12
12
---------------
@@ -20,32 +20,32 @@ submodules::
20
20
cd PythonEditor
21
21
git submodule update --init --recursive
22
22
23
-
**THIS NEEDS TO BE DONE BEFORE ANYTHING ELSE, OR IT WILL NOT WORK.**
24
-
25
23
Assuming you have Python 3 installed you can serve the editor like this::
26
24
27
25
$ ./bin/show
28
26
http://localhost:8000/editor.html
29
27
Serving HTTP on 0.0.0.0 port 8000 ...
30
28
31
-
As the script tells us, point your browser to http://localhost:8000/editor.html.
29
+
You can also look at the script content and execute the same, or similar,
30
+
command on a terminal as long as it serves the contents of this repository on
31
+
port `8000`. `This article <https://gist.github.com/willurd/5720255>`_ shows
32
+
other ways to achieve the same.
33
+
34
+
Then, point your browser to http://localhost:8000/editor.html.
32
35
33
-
It's also possible to run the editor directly from the file system like this,
34
-
for example::
36
+
Tests
37
+
+++++
35
38
36
-
$ firefox editor.html
39
+
There are two ways to run tests:
37
40
38
-
Or by double-clicking on the ``editor.html`` file from your file manager.
41
+
* A portion of the tests can be run in the browser
39
42
40
-
**IMPORTANT**: When the editor is run from the file system, the "sharing"
41
-
button is hidden. Because of security reasons, many local browsers won't allow
42
-
it to function correctly unless the editor is properly served from a network
43
-
domain rather than directly from the file system.
43
+
- Serve the editor and point your browser to
44
+
``http://localhost:8000/tests.html``.
44
45
45
-
Tests
46
-
+++++
46
+
* The full test suit can be run with Node.js
47
47
48
-
Simply point your browser to the ``tests.html`` file.
48
+
- ``cd tests && npm install && npm run test``
49
49
50
50
Tests are in the ``tests`` directory with their own README explaining how they
51
51
work.
@@ -54,19 +54,23 @@ Code
54
54
++++
55
55
56
56
* ace - a directory containing the Ace editor (http://ace.c9.io).
57
+
* bin - a directory containing useful scripts.
57
58
* blockly - a GIT sub-module containing Google's blockly project.
59
+
* docs - a directory containing more documentation for the editor.
60
+
* js - a directory containing the JavaScript code for running the editor.
58
61
* CHANGELOG - a record of how things have changed between versions.
59
62
* CONTRIBUTING.rst - a guide for people who want to contribute (you should!).
60
63
* editor.html - the page to be loaded by your browser.
61
-
* firmware.hex - copy of the "vanilla" MicroPython firmware used by the editor.
62
64
* help.html - a single page user facing help page.
65
+
* lang - a directory containing the editor translations.
63
66
* LICENSE - a copy of the MIT software license that covers this code.
64
67
* microbit_blocks - a GIT sub-module containing custom MicroPython blocks.
68
+
* micropython - a directory with the MicroPython hex files used by the editor.
65
69
* python-main.js - the JavaScript code for running the editor.
66
70
* README.rst - this file, the clue is in the name. ;-)
67
71
* tests.html - the browser based test runner.
68
-
* show.sh - a script that allows you to serve the editor from localhost. Requires Python 3.
69
-
* static - contains css, js and img sub-directories.
72
+
* show.sh - a script that allows you to serve the editor from localhost.
73
+
* static - contains third party css, js and img sub-directories.
70
74
* tests - contains the Python specific test suite.
71
75
* tests.html - point your browser at this file to run the tests.
72
76
@@ -86,80 +90,20 @@ auto-indentation.
86
90
87
91
All new scripts default to something simple and sensible.
88
92
89
-
The default name for a new script is ``microbit``. The default comment is
90
-
``A MicroPython script``. The default code is a short program to repeatedly
91
-
display ``Hello, World!`` followed by a heart. You can change these at any time
92
-
by clicking on them.
93
+
The default name for a new script is ``microbit``. The default code is a
94
+
short program to repeatedly display ``Hello, World!`` followed by a heart.
95
+
You can change these at any time by clicking on them.
93
96
94
-
It is possible to override the default name, comment and code via query string
95
-
arguments in the URL. For example, appending ``?name=My%20script`` to the
96
-
editor's URL will update the name of the script. Furthermore, appending
97
-
``?name=My%20script&comment=A%20different%20comment`` will override both the
98
-
name and comment. Please note that all query string arguments must be correctly
99
-
URL encoded - this especially applies to code. Use the "share" button in the
100
-
editor to generate and share such URLs with appended query strings.
101
-
102
-
The layout and functionality is deliberately simple. The buttons at the
103
-
top left, act as follows:
104
-
105
-
* Download - creates a .hex file locally in the user's browser and prompts the user to download it. The resulting file should be copied over to the micro:bit device just like when using all the other editors. The filename will be the name of the script with spaces replaced by "_" and ending in .hex. So "extraordinary script" is saved as extraordinary_script.hex.
106
-
* Save - download a copy of the Python source code. The filename will be the name of the script with spaces replaced by "_" and ending in .py.
107
-
* Blockly - arrange visual blocks to quickly create Python code. Moving such blocks will re-write your Python code and you may lose work. Furthermore, the arrangement of blocks is currently not saved, just the resulting Python code as described above.
108
-
* Snippets - allow user's to write code from pre-defined Python fragments (functions, loops, if...else etc). They are triggered by typing a keyword followed by TAB. For example, type "wh" followed by TAB to insert a while... loop. Clicking on the code snippets button opens up a modal dialog window containing instructions and a table of the available snippets along with their trigger and a short and simple description.
109
-
* Help - opens a single page in a new tab that contains user-facing help.
110
-
* Share - generate a short URL for the script. Share this with others. This button will be missing if run from the local file system.
111
-
112
-
Directly next to the large buttons are two smaller icons. The zoom in and
113
-
zoom out buttons that make it easy for teachers to display code via a projector.
97
+
The layout and functionality is deliberately simple. A description of the
98
+
buttons can be found in the [help page](help.html).
114
99
115
100
If you have a Python script or hex file on your local computer, you can load it
116
101
into the editor by dragging it onto the text area.
117
102
118
-
If you plug in your micro:bit and want to get the REPL you'll need to install
119
-
pyserial and run the following command with the appropriate permissions (such
0 commit comments