bbcmicrobit / pythoneditor Goto Github PK
View Code? Open in Web Editor NEWA MicroPython editor for the BBC micro:bit that works with browsers.
Home Page: https://python.microbit.org/
License: MIT License
A MicroPython editor for the BBC micro:bit that works with browsers.
Home Page: https://python.microbit.org/
License: MIT License
Is there an official place within this repo for release notes? I remember @jaustin telling me that @ntoll writes release notes.
We are now getting detailed release notes from the PXT team (see the link below) and I'd like to include links to release notes for the PythonEditor (web experience) too if they exist.
https://support.microbit.org/solution/articles/19000058445-pxt-release-notes
In situations like the image below where a block that requires some other input doesn't have it:
...it would be kind to the user to stop them from downloading a broken hex file. (Broken in the sense that because the block is missing a required input, we know that the parser will fail to interpret the script)
Can we detect that a block is missing a required docked other block?
If one has a moderately complicated blocks program, and one of the blocks is responsible for emitting an import
statement that causes an import error on the device, it is hard to work backwards to see which block caused the problem
For example, in #45 if the error were to occur in a large program, one would have to start removing 'number' related blocks until they found the one that caused the failing import.
Do we have a mapping for each import
line to the blocks that require it? Placing the cursor on that line could then highlight somehow the responsible blocks.
I guess another approach to this issues is "we shouldn't ever generate import errors from blocks, so this should be a nonissue" :)
in blocks mode the snippets button doesn't work. There's a dialogue telling you this.
I think it would be nicer for the user if the button changed visually to indicate this or even was removed. This would prevent the dialogue from being necessary.
I've followed the instructions in the README, but I can't create a script via TouchDevelop running locally.
After I click "Create Code" to create a new script, I get a page that looks like the following:
It looks like the browser's making a request for https://microbit.pythonanywhere.com/editor.html, which is returning a 404.
I am using the hosted version of this editor at python.microbit.org
I have a .hex file that I have saved and successfully flashed to my micro:bit, and this is also on my memory stick. I run into a workshop to then use this resource with 30 children, and I want them to be able to edit the script in the editor and innovate further. I have no authority to install any software on the computers in the school/public library or other place that I am delivering the workshop.
How do I get a .hex file from my memory stick (that I know has my python script embedded inside it) onto those 30 public computers so that children can see and modify the script, flash the resultant script onto the loan micro:bits, and even take a copy of their version script home with them on a memory stick that they provide, such that they can see the code they have created?
For unfortunate practical reasons, Mu does not work in this setup, as I go into a public space on short notice with no ability to install software, and have to use the arbitrary internet connected computers that they provide. All I am provided with is 30 public computers, each with an internet browser.
In another similar use-case, I might have my own website with step by step instructions on it, and a link that says 'click this link to get a .hex file you can start this project with'. They would download this .hex by clicking the link and save it locally, flash it onto the micro:bit, and then load it into the editor to modify it and re flash it.
I just found this comment in the code as part of the hexlify process.
Line 92 in 4e40946
Feature suggestion: I wondered if it would be possible to implement this check and pop up a message if the script is too big, so that users don't get a hex file they download that then doesn't work on the device?
I note that this is implemented (and works well!) In Mu already:
https://github.com/mu-editor/mu/blob/0f05abac63319a2e15ef5cd32f846f712b07dd17/mu/logic.py#L375
Thanks
I found the setup instructions non obvious:
This editor works with any modern web browser.
To grab the GIT submodules you should issue the following command:
git submodule update --init --recursive
THIS NEEDS TO BE DONE BEFORE ANYTHING ELSE WILL WORK.
Assuming you have Python 3 installed you can serve the editor like this:
Actually, what you have to do is:
git clone https://github.com/bbcmicrobit/PythonEditor
cd PythonEditor
git submodule update --init --recursive
Independently of versioning management by URL, there should be a simple way to identify the version of the editor served just by looking (or going through a menu) at the page.
This is a tricky to track down issue, so hopefully posting it here we'll find other people with the same problem...
Though we haven't ever seen or reproduced it ourselves in the foundation, a number of people have sent us hex files that are missing large chunks of data, and the result is that the checksums fail and DAPLink refuses (correctly!) to flash the file.
The error DAPLink puts in the fail.txt is:
The hex file cannot be decoded. Checksum calculation failure occurred
Missing chunks are not on line boundaries.
(this is a complex one that I think needs some discussion - opening this issue as a place for that)
At the moment in blocks, as far as I can see, any block on the canvas will cause code to be generated and likely run. There aren't 'hats' or 'events', not even an 'on start' one.
This can cause a few possible issues.
For one, it's fundamentally different to scratch
In this case, the 'hmm' will never happen.
The difference is not in itself a reason to change, but In the past we've seen kids use 'undocking' blocks as a way to 'comment them out' (IE you build a complex set of blocks and then 'undock' them in order to stop them running. This is one good reason to think about how things work.
(it's also different from PXT, too)
Secondly, it can create some confusing things on canvas if your project has grown and then shrunk again.
For example, someone who knows how to code will easily spot the issue here:
...but for someone who is only focused on the blocks this could be really confusing. This is a slightly artificial example, but I think the problem in general is real, especially given the lack of clear notification that things are not currently visible, etc. (see in part #42 )
Note that PXT removed 'hats' early on in development and decided to add them back. There's a good discussion about that here:
microsoft/pxt#849
When adding a logic block like ( ) >= ( ), your next action will be to put a variable or a pin value on one side.
But you then have to search for the integer block (hidden in math, why not)
Is it possible to have default logic block like:
( ) >= ((0))
Since 0.1.0 we've been able to move between different versions of the editor. Hooray!
However, currently the contents of the script buffer (IE the users' code) gets lost between this version migration. In the case that the user entered with a script in the URL we will preserve that script but not any subsequent changes.
I believe the following rule is good:
Whenever moving between editor versions, put the buffer contents into the URL bar so that the script migrates between versions
Implementation-wise there are a few privacy gotchas - If we put their script in the URL bar then it can/could end up in server logs. If we put it in a cookie we have to mention that we will use cookies in privacy policy.
(This one probably isn't trivial, as I think it's partially a blockly/Python limitation)
One of the things that blocks is quite good at is avoid syntax errors.
However, our current implementation doesn't protect the user from type error as well as it could.
For example, the following code fails as soon as it is run on the micro:bit
PXT gives slightly more useful feedback:
Do we have a way of giving more immediate feedback to users about type mismatches? Or even better, perhaps (although it's spooky action at a distance) automatically inserting the required conversion so it 'just works'?
When switching on blocks after being in 'code mode' the program does not update even if there are already blocks placed.
This can become confusing when switching between the modes, as it appears that your program has been preserved when it has not been. A video shows this more clearly
I think this could be mitigated by performing whatever action is performed when a block is actually selected (end of the gif) as soon as blocks is turned on.
One thing that seems to aid transition from blocks to coding is the ability to explore the API in the same way the blocks display it.
Could we have some visual API representation similar in some ways to the blocks display format so that kids can explore the API alongside coding when not in blocks mode. Perhaps something like 'snippets on steroids' or 'docs with fewer words'
At the moment the String.charCodeAt()
method is used to get the user script character codes, and it's return value is stored in a Uint8Array
.
If the value returned is larger than a byte, as it would happen with some UTF-8 characters, then some of that information is lost and the wrong character is encoded into the hex file.
Lines 84 to 92 in 3d30f7f
This is easy to reproduce, simply create a hex file with a UTF-8 character larger than a byte, download the hex, and load it back into the editor.
# UFT-8 character longer than a byte: Σ
Becomes:
# UFT-8 character longer than a byte: £
As the chracter 0x03A3
(Σ) has been encoded as 0xA3
(£)
When creating an image, you have to select the brightness of each cell.
Is it possible to have a cell on the side representing the current selected brightness and use it on single click?
If a user is coding using blocks, the blockly content gets lost at the 'save', 'download' or 'share' stage.
This makes it hard to, for example, share skeleton blocks programs, or even return to a previously incomplete blocks program.
Looking for the 'delay' related blocks, I'm not sure 'Microbit' is where I'd expect them to be.
I'll test this with kids on Sunday, but I'd say I'd expect 'Timing' or 'Time' to be listed alongside loops, text, lists, etc underneath the other function blocks
The new Blockly is brilliant. There are some really nice Python features you have surfaced into blocks.
However, there are a lot of palettes and a lot of blocks, and it looks a bit overwhelming as a starters language the first time you try it.
Would it be possible to have a beginners and an advanced mode? Where beginners mode contains a smaller number of palettes and blocks to get people started, but then the advanced mode adds all the other ones in?
I'm not sure yet how we would choose the subset that goes into beginners mode - perhaps watch some children using the editor for the first time and see which blocks they use, and base it on that? Or look at a representative base of existing python resources coded into blocks, and only include the blocks required to implement those resources?
The fact that Python your blocks program is generating is displayed alongside your block code is really useful. However, it's somewhat confusing that you cannot edit the text.
The purple background of the code that is present when the blocks pane is focused is lost when the cursor is placed in the text field.
One possible suggestion would be to hover a little message above the cursor of the editor that says "While you're in blocks mode you can't edit the Python code. Please turn off blocks if you'd like to edit the code here"
I'm sure there are other UI options for indicating why the code can't be changed while blocks are present, but I think it'd be helpful for there to be something.
If you create blockly code and use the share feature, when you use the URL, all you get back is the textual Python code, not the blockly code.
A very active member of our community in Kent is looking to run workshops using Raspberry Pi 3 and micro:bit. They wish to use a blocks based approach to coding the micro:bit.
I would like to recommend to them that they try this new release of this web based editor, but they have to build their SD cards this Saturday (11th Feb) in order to be ready in time.
Can you let us know which precise version of the Raspberry Pi OS this new version was tested against, and a list of any known issues with it, so that the volunteer team in particular can correctly configure the editor with confidence that it will work in front of a room load of children?
Additionally, if you have any resources such as screen shots or documentation or worksheets or online documentation that you are aware of for this new editor (even in early beta), could you send through some links to help them get started, as they will need to throw together a quick worksheet for this having never used it before.
Sorry for the somewhat bold request - but the team have a huge amount to prepare to get the whole event organised and prepared of which this is just one aspect of the event, so we would like to know that this is just going to work. If you're not confident that this will work, we would rather you say so now, and I'll recommend that they cancel this aspect of the workshops until we are confident that it will work on this platform.
I tried a version of this master branch first week of January, and when I pressed on the blocks button a blank pane appeared and there were no blocks on it. This was on a Raspberry Pi 2 using a version of the Raspberry Pi official OS as installed about July 2016 I think it was the last version of Jessie before they released Pixel, as it did not have the desktop background. The Pi has since died so I can't be sure the precise version. I also tried to press the DOWNLOAD button for the default code in the text editor, a window opened and then closed and there was no .hex file saved anywhere on the Raspberry Pi filing system, so I just couldn't get it to work (I did a search for .hex files in the os filesystem and nothing came back).
However, this is a great opportunity to get feedback on the new editor, if you think it is now ready and stable on the Raspberry Pi 3. It will be using the standard browser installed on the Pi 3 OS, whatever that is, and whichever version of the OS you advise us it has already been tested on. The devices will not be connected to the internet for the duration of the workshop, and the cards will be pre-installed 1 week before the event.
Thanks very much in advance for your help and expert advice.
It would be good to be able to add modules that aren't included in the default build.
It might also be nice to be able to remove modules that are included by default but that are using flash that the program could reclaim.
One possible model for this would be to drag and drop a module into the browser and have included modules listed on the right hand side where the 'instructions' lived on the microbit.co.uk site
For the main microbit.org site we are using CrowdIn for translation. It would be good if the strings for the PythonEditor were broken out in such a way that we could translate this editor for each country at the same time as we translate the main site.
There are lots of enthusiastic translators around micro:bit so this should really be a case of making it easy for them :)
On the ALPHA Python micro:bit blocks I can't get the Image Block to snap onto the Animate Images Block
Hi, for beginners it is important even in py :)
I've seen it in Greenfoot.org
Then in py based CodeCombat.com, Codesters.com
http://www.mdpi.com/electronics/electronics-05-00033/article_deploy/html/images/electronics-05-00033-g005-1024.png
https://adamasbasecs3.files.wordpress.com/2015/06/aaa.jpg
@ZanderBrown has shared this good accessibility article in #64 (comment): https://sarbbottam.github.io/blog/2016/06/11/use-button-if-you-mean-it
We already do some of the things indicated there, and should add the others as well.
I'd like to be able to easily convert numbers to strings using blocks. Here's a simple example of a program where this would be useful
The 'create text with' block that exists currently has two inputs, and the hover text says "create text by joining together any number of items"
As the image of the block has two 'inputs' it is not clear that this block can also be used for a single item (although I agree 'any number of items' does clearly include one item!):
Using the 'gear' on the 'create text with' block you can achieve this
However, I think it would be much clearer to add another block, perhaps "Convert to text" and the "create text with" could be "Combine items into text" or similar?
@carlosperate thoughts?
Sometimes when people just want MicroPython on their device we recommend to flash an empty script. This works fine in Mu, but in the Python Editor the downloaded hex will still write to the address 0x3E000 an empty script, with the "script start header" is still there.
:020000040003F7
:10E000004D50000000000000000000000000000073
We should detect an the empty code editor and not add this to the hex.
For larger programs, it would be nice to be able to adjust the proportion of the screen given to the 'text' part of the program and the blocks canvas
Even with some of the 'standard' blocks, the allocated canvas on my machine is not enough to avoid scrolling
There are a few options that come to mind
I was given this feedback by a teacher that is using the new Python editor hosted at python.microbit.org.
The new editor is much better and using this with students from next week so fingers crossed. Will it remind students if they try and leave site and not downloaded? I can just see students making changes and forgetting to save as used to Google Drive and Microsoft products reminding them not to leave or close without saving?
I'm not sure how much work this might be to implement, but I wondered if you could put some thought into it, as it seems like a typical problem that a classroom teacher will experience regularly. Thanks.
The blockly interface is amazing. However, one thing that makes it feel very different from the existing PXT experience is the absence of round-tripping.
I found a paper on round-tripping by one of the blockpy contributors here, in case it is of any use to you for future developments:
Feedback from teachers I discussed and demonstrated the Python web editor with (mostly at the BETT exhibition, but also dealing with some confusion that surfaced in various support tickets).
We have a save button, could we have an open button? It's not clear to some users that to open a file, you drag and drop the .hex file onto the editor window.
Having Save and Open would also be consistent with all other applications that teachers and children are used to using in school, and would be self-prompting that this is the way to reload an existing file back into the editor.
The code snippets button should be inactive or removed when Blockly is opened.
At the moment it will replace the editor content, which only gets replaced with the blocks code when a change in the workspace takes place.
When trying to initialise the submodules:
$ git submodule update --init --recursive
Submodule 'blockly' ([email protected]:google/blockly.git) registered for path 'blockly'
Submodule 'microbit_blocks' ([email protected]:PyBlocks/microbit_blocks.git) registered for path 'microbit_blocks'
Cloning into 'blockly'...
The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
fatal: clone of '[email protected]:google/blockly.git' into submodule path 'blockly' failed
So it didn't clone either repository.
Based on http://stackoverflow.com/questions/9299651/git-says-warning-permanently-added-to-the-list-of-known-hosts its an SSH related issue, so if we configure the submodule using https instead it will probably get around all this.
I'm trying to view the Big Food Survey code on the BBC micro:bit website, here is the URL
https://www.microbit.co.uk/app/#edit:64b472eb-b00e-4d13-8267-ba678e8f83ce
I'm on a Macbook Air 11 inch screen, and I can only see 62 characters per line maximum, the zoom out button does not zoom any smaller than this, and I can't seem to turn of the pane at the right hand side.
It's normal to allow up to 80 characters per line as a minimum for code listings.
The screenshot below is with the browser window (google chrome) maximised to the full screen size
Instead of:
I had to:
There was no chance to tell them that I was an adult!
The 'change variable by' block causes the following import statement to be emitted:
from numbers import Number
Which in turn causes an ImportError on the device.
It also generates rather confusing code:
count = (count if isinstance(count, Number) else 0) + -1
I notice the Blocks Menus are organised in alphabetic order. Whilst there is a logic to them being in that order, since most students will graduate from the regular BLOCK or PXT BLOCK to Python Block I think it would help the student if the menus items were (as near as possible) in the same order with the same names and each menu item contained (as near as possible) the same Blocks as BLOCK/PXT BLOCK.
Kids tend to see both the 'Download' and the 'Save' button and wonder which one they should use (and adults tend to be even more confused)
I think it would be good to be more explicit about the difference and make the 'save' feature to generate a python file slightly less on the 'fast path'. Here's a super-quick mockup to show intent.
When using this way of installation it can't be accomplished. It starts, download a few files and when it gets to the bigger ones it gets lines of error and stops. I've tried in my acer atom laptop (with raspberry pi distribution) and my ubuntu 16.04 64bits, with the same issues. I've tried thousands of times. Each time is different. Doesn't always stop in the same file, but normally in the big ones. Than tired, I've tried at https://codewith.mu/ and I downloaded mu-0.9.13.linux.bin, and my distribution doesn't know what to do with that file, even if I've made it executable.
$ pip3 install mu_editor
Collecting mu_editor
Using cached mu_editor-1.0.0b13-py3-none-any.whl
Collecting pyqt5==5.9 (from mu_editor)
Downloading PyQt5-5.9-5.9.1-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (104.6MB)
39% |████████████▋ | 41.3MB 27kB/s eta 0:38:22
Exception:
Traceback (most recent call last):.....
or:
$ pip3 install mu_editor
Collecting mu_editor
Using cached mu_editor-1.0.0b13-py3-none-any.whl
Collecting pyflakes==1.6.0 (from mu_editor)
Retrying (Retry(total.....
$ pip3 install mu_editor
Collecting mu_editor
Using cached mu_editor-1.0.0b13-py3-none-any.whl
Collecting matplotlib==2.0.2 (from mu_editor)
Using cached matplotlib-2.0.2-cp35-cp35m-manylinux1_x86_64.whl
Collecting pyserial==3.4 (from mu_editor)
Using cached pyserial-3.4-py2.py3-none-any.whl
Collecting pyqt5==5.9 (from mu_editor)
Downloading PyQt5-5.9-5.9.1-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (104.6MB)
70% |██████████████████████▋ | 73.8MB 25kB/s eta 0:19:48
Exception:
Traceback (most recent call last):....
...using GitHub here, but please @ntoll redirect me if you'd like this in a different forum. Ultimately aiming for visible/public enough
One of the questions we (at micro:bit Foundation) get a lot in relation to the Python Editor and MicroPython in general is "How can I make a library to support my accessory?". At the moment, people tend to publish example code (hex files) and go from there.
Our current 'single file' model makes it hard to do much else, as far as I can see.
So I think there are two questions
Given the current state of play, what's the best advice for someone wanting to write python code to support an accessory with micro:bit - IE what should we ask them to provide for MicroPython?
What can/should we do in the future to improve this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.