The source code is nice and simple, although it relies an two patches which have not yet made it into a release of PyGameZero (so mark this as coming soon). One patch adds joystick support (i.e. what you do with the gamepad) and the other makes it easy to flip sprites.
Coming soon to a PyGameZero/Mu release near you!
Friend of Mu and community supporter extraordinaire Les Pounder writes a blog containing lots of quick, fun and beginner-friendly projects. He calls this sort of thing “tinkology” – a term I really like. Playful tinkering is such a wonderful way to learn and relax. Can you guess what editor he uses? Nope, it’s not EMACS or VI. ;-)
What I love about Les’s blogging is its consistency: there’s always something new and it’s always really imaginative and fun. Les is a great source of ideas for lessons, projects or learning activities for beginner programmers. For instance, on most Tuesdays he writes a “Tooling Tuesday” entry to his blog and many of these have a Python slant to them. Other related series of posts include “Micro:bit Monday” and “Friday Fun”.
Mu related highlights include:
- Friday Fun: Python Pollen Projects
- Tooling Tuesday - Python3 GeoPy
- Tooling Tuesday - Google Image Search With Python
- Tooling Tuesday - easygui
Any of these could form the basis of a cool project, set of lessons or after school code-club activity. So, here’s to Les, his blog and fantastically imaginative projects.
Thank you Les!
What does software development look like? Here’s a short video / visualisation of the creation of Mu as told via the interactions, interventions and changes by developers to Mu’s own source code hosted on GitHub.
What exactly are you looking at?
- The faces represent the developers.
- The multi-coloured blobs are the source code files that make up Mu.
- The lines between the source code blobs show how the files are organised together into directories.
- As time passes, developers can be seen to change, add and delete files as the project matures.
I used the
gourcetool turn the commit history of Mu’s development on GitHub into a video. I added some Creative Commons licensed music and the results look and sound quite effective. What I really like is how the video reflects the wide variety of people and types of contributions made to the source code for Mu. Together, we’re continuing to build the best editor we possibly can for beginner programmers and those who support them.
Ever wanted a pathalogically conflicted artifical intelligence for your own home? Why, of course you do! Adafruit’s CRICKIT board has you covered (along with instructions for how to program it via Mu).
The Crickit (Creative Robotics and Interactive Construction Kit) is a an add-on for the Circuit Playground Express board. Cricket aims to make it easy to make friendly robots and thus make friends with robots (now there’s a sentiment we can all get behind). Essentially, Crickit complements and amplifies the CPX board by making it extraordinarily easy to interact with robotic “bits and bobs”.
What I love about this project is how simple it is to make and program. Once complete, just press the glowing red button to hear audio clips of HAL. The source code is less than 50 lines of Python and, perhaps most importantly, you have a chance to replace the recordings so your HAL is no longer an uncooperative controller of on-board systems, but perhaps a friendly computer in the spirit of Cricket. What’s more, this project is relatively easy to modify to other concepts such as responsive cuddly toys or the world’s most friendly door bell (remember those doors from The Hitchhiker’s Guide to the Galaxy?).
EuroPython (one of the world’s largest, most friendly and culturally diverse Python programming conferences) happened last week in Scotland. Sadly, for personal reasons, I was unable to attend. However, it was great to hear via social media that Mu was used in the opening conference keynote by Pythonista-extraordinaire David Beazley. Not only is it wonderful to see Mu used by someone so well respected in the Python community at such an auspicious occasion, but David’s use of Mu is a wonderful example of Mu’s use as a pedagogical tool. Remember, Mu is not only for learners, but is also for those who support them (i.e. teachers).
What do I mean by pedagogical tool?
The stereotypical example is a blackboard upon which the teacher chalks explanations, examples and exercises for their students. Teaching involves a lot of performative explanation – showing, telling and describing things as you go along; traditionally with the aid of a blackboard. This is a very effective pedagogical technique since students can interrupt and ask questions as the lesson unfolds.
David used Mu as a sort of interactive coding blackboard in his keynote introducing the Thredo project. He even encouraged listeners in the auditorium to interrupt as he live-coded his Python examples.
David and I have never met in real life, although our paths have crossed online via Python (and, incidentally, via our shared love of buzzing down long brass tubes). So I emailed him to find out how he found using Mu. Here are some extracts from his reply (used with permission):
There are some who seem to think that one should start off using a fancy IDE such as PyCharm, VSCode, Jupyter Lab or something along those lines and start piling on a whole bunch of complex tooling. I frankly disagree with a lot of that. A simple editor is exactly what’s useful in teaching because it cuts out a lot of unnecessary distractions.
From a more practical point of view, I choose to use Mu for my talk precisely because it was extremely simple. I do a lot of live-coding in talks and for that, I usually try to keep the environment minimal. […] Part of the appeal of Mu is that I could code and use the REPL without cluttering the screen with any other unnecessary cruft. For example, I could use it without having to switch between terminal windows and I could show code and its output at the same time in a fairly easy way.
This sort of feedback makes me incredibly happy. David obviously “gets it” and I hope his example points the way for others to exploit the potential of Mu as a pedagogical tool. David also gave some helpful suggestions which I hope we’ll address in the next release.
David’s keynote is a fascinating exposition of what you may want from a Pythonic threading library – it also has a wonderful twist at the end which made me smile. I’d like to encourage you to watch the whole presentation either via EuroPython’s live video stream of the event or David’s own screen cast of the keynote, embedded below:
Finally, the exposure of Mu via EuroPython had a fun knock on effect: someone submitted the Mu website to Hacker News (one of the world’s most popular news aggregation websites for programmers). By mid-afternoon Mu was voted the top story and I had lots of fun answering people’s questions and reading their comments relating to Mu.
My favourite comment, which I’ll paraphrase below, will become Mu’s tag-line:
“Python is a language that helps make code readable, Mu is an editor that helps make code writeable.”
We’re pleased to announce the release of Mu 1.0.0, a Python code editor for beginner programmers! There have been only minor changes since the release candidate, full details of which can be found in the changelog. As always, feedback and bug reports are most welcome. We’ve also completed and updated the tutorials on the website.
Many people have been involved in getting Mu to 1.0, and, if you use Mu, it would be a wonderful gesture if you could thank them via social media. Details of who to thank can be found here.
Some interesting facts and figures about Mu:
- 34 people have contributed code.
- There are currently only 3907 lines of Python code in Mu.
- We have 100% unit test coverage.
- Our code quality rating on LGTM is A+.
- There have been 1115 commits since the project was started on 7th December 2015.
- We’ve closed 341 issues.
- We have extensive developer documentation.
- Our online chat is growing.
Finally, earlier this week, we had our first ever Mu-moot in the MUseum Tavern in London. Not everyone could make it, but the photo below is of most of the core contributors:
(Al Broomhead [front-left], Martin O’Hanlon, Zander Brown, Dan Pope, Steve Stagg, Carlos Pereira Atencio, Tim Golden and Nicholas Tollervey [front-right].)
Everyone went away with an exclusive Mu t-shirt, the custom designs for which I’ll post on social media.
But before doing anything else, I’m going on holiday for a week. :-)
The release candidate for Mu 1.0.0 is out! This is the last step before the final release of Mu 1.0. Apart from a few minor bug fixes, the biggest change from beta 17 is the inclusion of various translations for the user interface. Full details can be found in the changelog.
Many thanks to the following people for their magnificent work on the following translations:
- Chinese (incomplete), by Pydo.
- Japanese, by Minoru Inachi.
- French, by Gerald Quintana.
- Spanish, by Carlos Pereira Atencio.
- Portuguese, by Tiago Montes.
I would love to include more translations in the final release, especially if they’re in one of the following languages:
(This list reflects both reach and accessibility of languages so Mu is usable by as many beginner programmers as possible.)
Other highlights include a fix to allow users of Adafruit devices to save a file called
code.py. This was getting erroneously caught by the new “shadow module” feature which, in this specific case, doesn’t apply. Zander Brown continues to make extraordinary progress in making the user interface both great to look at and consistent across all platforms. We had quite a bit of feedback from teachers who value such UI consistency: it allows them to create resources that apply to all platforms, thus avoiding all the complications of, “if you’re on
<platform>, then this will look different” interruptions in the flow of such resources. Finally, Tim Golden and Jonny Austin have done sterling work testing the various fixes for problematic edge-cases in the new BBC micro:bit flash functionality.
I had a stonking time yesterday afternoon with Harvey Sharman, who runs workshops for young coders in a library close to where I live. This particular afternoon was spent in the company of a group of eager eleven-year-olds. Harvey’s learning activity? Use Mu to program “transmitter” and “detector” micro:bits so the kids could organise a treasure hunt in the library. Let joyful coding chaos ensue!
I first became aware of Harvey’s work via the following tweet:
One of my pupils inspired in Python Mu hard coding the International Space Station project to collect live data of latitude and longitude coordinates to locate the actual position of the space station using an A3 print of the global map with coordinates. @ntoll 🛰️ @rebeccafdp pic.twitter.com/Ke2JKzDiju— Harvey Sharman (@BitawsBrackley) June 28, 2018
It was a stroke of luck that I live in the next village from Harvey and I just had to investigate. As a result I was invited to observe Harvey and his students in action.
The group of eleven-year-olds sped through the task of writing the code, checking it and flashing it onto the micro:bit. Then the group split in two: half were unleashed into the wider library to hide their “transmitter” micro:bits and upon their return the other half were let loose, waving around poles with their “detector” micro:bits stuck on the end. If the “detector” got close to a “transmitter” it would start to bleep and the “X” on the micro:bit’s display changed to a number to indicate the relative proximity of the devices.
Imagine, if you will, a sleepy afternoon at Brackley library: the knitting circle quietly click-clacking in one corner, a pensioner’s jigsaw club (armed with tea and biscuits) in yet another, and a hoard of enthusiastic eleven-year-olds waving around blinking and bleeping poles at anything and everything (including the afore mentioned knitting circle and jigsaw club) in an attempt to find “treasure”.
To say the kids had a huge amount of fun is an understatement (to their credit, the other library users were very patient and I was especially pleased to see maniacal grins on the faces of the librarians as the kids explored all the various sections of the library). Public libraries are such an asset to our communities since they’re the only place the pensioner’s jigsaw club could rub shoulders with eleven-year-olds from a code club. Two different parts of the same community got to see what each other were doing.
Afterwards, when the kids had left, we recorded the following video to explain how things work:
The source code is very simple and takes only minutes to type in. The detector works by checking the strength of radio signals. The stronger the signal of a received message the closer you are (and the higher the number displayed and the bleeps from the speaker). The transmitter micro:bits constantly send out signals at the lowest possible power so the signal is only detected when you’re stood close by (I’d say around 3 to 4 meters). This is beautifully simple and ingenious and could form the basis for all sorts of interesting classroom activities and learning opportunities. How might you improve the code?
Harvey tells me that Mu makes Python programming easy for his young coders and my own observations during the workshop confirm this. It took moments for the kids to figure out what to do. It was also cool to see them help each other and make suggestions for using Mu. For instance, once one kid figured out how to use the autocomplete functionality to avoid typing long words, they were all at it after the inevitable, “hey, look at this!”.
I look forward to more projects, games and “hacks” from Harvey and his young charges (and I’ll keep you posted!).
We’re pleased to announce the availability of Mu 1.0.0-beta.17, a Python code editor for beginner programmers! This is the final beta version before a release candidate later this week and the final 1.0 release sometime next week. This version is feature complete for 1.0. Any further changes will be bug fixes or cosmetic changes rather than new features.
The full list of changes can be read in the developer documentation. However, highlights include:
- A major re-write of how MicroPython code is flashed onto the BBC micro:bit. If there’s one thing we’d love to be tested by users, it’s this! All feedback most welcome (submit a new issue if you find a problem or discuss things via online chat).
- The latest and greatest version of MicroPython for the BBC micro:bit.
- Updates to the Python visual debugger (which is working really well).
- Protection from “shadow modules”. When many new programmers first save, for
turtlebased code they call their file
turtle.py. This breaks Python in a subtle yet opaque manner for beginners. Of course, their new
turtle.pyfile takes precedence in the import path, so where their code says
import turtleit is, in fact, trying to import itself..! Not a good situation for anyone, let alone a beginner programmer. As a result, Mu will complain if you try to give a file the same name as an existing module on your Python path. We know from extensive feedback this feature will save hours of confused head-scratching for beginners and teachers.
- We’ve also added a very simple yet remarkably useful “find and replace”
dialog which you can access with the
Ctrl-Fhot key combination.
- Talking of hot key combinations, if you highlight some text and press
Ctrl-Kit’ll be toggled between commented and uncommented. If no text is highlighted, the current line is toggled between these two states.
- Mu has been updated to use the latest version of Qt as its GUI framework.
- Plenty of minor fixes, tidy-ups and bugs squashed.
The next release will be a bug-fix “release candidate”. This will be a dress rehearsal for the final release which will follow soon after. Happily, most of Mu’s test, build and package infrastructure is automated. However, since this is still a process with several different components that need to be synchronised and checked (such as blog posts announcing the release and documentation updates) and some manual interventions (such as digitally signing the installers for OSX and Windows) we want to make sure we get this process right first time!
As always, feedback, bug reports and ideas would be most welcome!
Caitlinsdad has created colourful Rainbow Pride Traffic Lights with Mu and CircuitPython. This is great timing since Pride month just finished and today tens of thousands of people are taking part in the Pride in London Parade. Thanks to Adafruit for the heads-up!
So I have an Adafruit Circuit Playground Express board to play with. This project seems like a good way to learn Circuit Python programming and to get more familiar with the Mu Editor and REPL function.
Thanks to some epic cardboard crafting, Neopixels, a healthy dollop of paint and experimentation with timings in the CircuitPython code, the results are a customizable rainbow light-show:
By day Keith is a healthcare informatics professional. By night, like many of us, he builds robots and other Maker-type projects. This particular project blinks different messages in Morse code. You can configure the LED colour as well as toggle the buzzer (so the board “bloops” Morse code too).
He says, “I love the idea that I could use Python to program a microcontroller” and explains the origin of the project as follows:
I was at the San Mateo Maker Faire this year (I was at the first one, and have been there or NYC Maker Faire every year since). I had brought the CPE with me to play with in case I had any free time (I hadn’t had time to really mess with it - big project at work). My flight Sunday night was cancelled, so I thought I might go to the Bring-a-Hack event. I didn’t want to show up empty handed, but all I could think up was a lame demo of the CPE. I quickly re-reviewed some tutorials, and wrote a quick program in my hotel room. Didn’t work at all. Tried different things, cut-and-paste sample code (which all worked), finally gave up. At that point I was tired, and had to get up early for a flight, so I canned it. When I got back to St. Louis and read through the code again, I realized I had thought that time.sleep was in milliseconds (like Arduino Delay), rather than in seconds. The original code I had written was actually fine - just a thousand times slower than I was expecting. Once I fixed that, it was fine. I’ve since cleaned it up a little.
Thus proving the old adage that, “good things come to those who wait”. ;-)
Keith has helpfully provided a video of his code in action:
The project’s source code contains a complete implementation of a Morse code transmitter that could form the basis for many future beginner-friendly projects. If you’re interested in changing the transmitted messages you should modify lines 92 and 95. The Morse code definition is in a Python dictionary on line 22 and the loop, starting on line 98, is a great example of how to convert characters into Morse code. Check it out!
I wonder, how hard might it be to implement simple signal processing using the Circuit Playground Express’s microphone or light sensor to detect the message transmitted from a second device and emit the result to the CircuitPython REPL? (That’s a trick question… it’s very easy, but I leave it as an exercise for the reader to solve.)
As for Mu, Keith says it is, “certainly convenient for programming the CPE (and BBC micro:bit). The biggest thing I miss is a keyboard shortcut to comment/uncomment bits of code. That would make troubleshooting so much faster.” Check out progress for this feature request on our issue tracker.
Thank you Keith for such an easy-to-follow Morse code project!
Everyone else, if you extend or re-use this code, let us know! We love to shine a light on the hard work of Mu users (no pun intended). :-)
Leila and Emma got in touch to tell us they’ve made themselves a stylish homemade clock! Using an Adafruit M0 Trinket, a quad 7-segment display and various other components they hacked all the CircuitPython code together in Mu! Read on to learn more…
I first met Leila and Emma in 2015, when Trans*Code was first welcomed to PyCon UK. On subsequent meetings it has always been a great pleasure to hear of their homemade electronics projects and how they’ve thought up ever more creative and interesting ways to use MicroPython or CircuitPython in their work. They have been great supporters of Mu since the very earliest releases, so “thank you” both for your encouragement, feedback and support.
When the call went out for user-contributed projects for this blog, it didn’t take long for them to submit the first contribution, and what a fun project it is!
Their own digital alarm clock broke, and none of the replacements fitted their requirements, so rather than buy a new one they used it as an opportunity to learn and make their own.
What I love about this project is that it took several attempts to get it right. In the end they came up with a device that worked with a much simpler design than their original solution (that didn’t work at all!). This is a common occurrence: it takes time to work out how to solve a problem and you’re likely to encounter unforeseen problems along the way. Only after “playing around” and experimenting for a bit will a simple, elegant and (most importantly) working solution emerge.
Another aspect of the project that I really like is its Wabi-Sabi-ness. I’m a big fan of Wabi Sabi (while the linked-to Wikipedia article is interesting, I recommend this wonderful little book for those who want to learn more). Wabi-Sabi is the beauty found in impermanent, incomplete and unconventional objects. The development of, and solution for this project is a wonderful example of such beauty.
Finally, the code they created in Mu has a really cool feature to handle button presses to change modes (their clock not only tells the time, but will display the date and year!). This is another important aspect of the project: Leila and Emma are in control of their digital device and, if they feel so inclined, are free to change how it works or fix any bugs. They can hack it!
You can read Leila’s full write-up of the project, including source code and circuit designs at her blog.
Great work Leila and Emma! :-)
Adafruit, the brainchild of Limor ‘Ladyada’ Fried, was founded to create the best possible resources, boards and designs for learning about electronics and programming. Over the last decade she and her colleagues have surpassed their initial goal and become the touchstone for inspiring a community to engage with making electronic devices for serious, playful and educational use. Perhaps most importantly, Limor and her colleagues have become worthy role models to many for whom electronics or programming may, at first, appear “not for them”. They have been celebrated by the WhiteHouse, written about in high profile magazine articles (such as for WIRED and MAKE magazines) and been the recipients of several awards.
They are fearless in their support for and promotion of under-represented groups in technology. As they say on their website,
… we’ll do our best to shine a light on the untold stories of women in STEM and underrepresented champions from all over the world.
Happily, Adafruit support their own flavour of MicroPython (think of it like an Adafruit “distro” of MicroPython) called CircuitPython. CircuitPython provides a uniform and consistent API for all the many and growing number of Adafruit boards that it supports. This makes it very easy to transfer your skills and knowledge between different types of device, be it a minute Gemma board or the spectacularly colourful and feature-ful Circuit Playground Express.
Mu has a CircuitPython mode which understands how the boards work (for example, you store your source code on the connected device’s USB storage). It also provides a couple of short-cut functions to help you interact with your CircuitPython device. For example, reading from and interacting with the connected device’s serial connection is but a button press away:
Perhaps my favourite feature is the plotter, which allows you to visualise data coming from the connected device. The plotter was originally contributed by Limor herself. The following video shows Limor explaining how to visualise the data coming from the light sensor of a Circuit Playground Express with the plotter built into Mu (originally blogged here):
What’s really great about this example is how short the Python code is:
There are plenty of projects and videos for using CircuitPython and Mu on Adafruit’s website.
Check it out..! If you create something awesome, please tell us about it! :-)
Have you ever wanted to write a game? It turns out that Mu and PyGame Zero make this really easy for beginner programmers. Read on to learn how the author used both to create a goofy game for the wonderful PyWeek event.
PyWeek is a fun, community-organised game-making event / competition that doesn’t take itself too seriously. As the website says, the PyWeek challenge:
- Invites entrants to write a game in one week from scratch either as an individual or in a team,
- Is intended to be challenging and fun,
- Will hopefully increase the public body of game tools, code and expertise,
- Will let a lot of people actually finish a game, and
- May inspire new projects (with ready made teams!)
As the name suggests, all entries should be written in Python and incorporate a theme announced at the start of the challenge.
PyWeek happens a couple of times a year and in April it was organised by my buddy Dan Pope (aka lordmauve). Dan has many claims to Pythonic-fame, but the one I’m going to focus on today is that he’s the creator and maintainer of a wonderful library called PyGame Zero. As the name suggests, PyGame Zero is based upon another wonderful library called PyGame (maintained by another equally talented buddy, René Dudfield). PyGame makes it very easy to create graphical games in Python. PyGame is highly portable which means that games made with PyGame will run on plenty of platforms. PyGame Zero is a beginner-friendly wrapper around PyGame.
Dan created PyGame Zero after working with a group of teachers at PyCon UK’s education track. Since he’s a gifted and experienced game developer he was able to create a simple graphical game in about an hour. As he did so, he explained to the watching teachers exactly what it was he was doing. However, the feedback from the teachers was clear (paraphrased), “While PyGame might be easy for you (Dan), the kids we teach would find it hard to put together 10 lines of Python, let alone the 500 line you just created; we need a way that makes it easy to create something cool with very little code”.
And so, the seeds for PyGame Zero were sown. Dan has created a simple and easy-to-understand wrapper that enables learners to make something graphical in only a handful of lines of code. If you’re interested in learning more about PyGame Zero (including a really great tutorial) go check out the beautifully written project documentation.
Since Mu has a PyGame Zero mode, I thought I’d enter the most recent PyWeek and try to create my first ever game using just Mu and PyGame Zero. The theme was “two worlds” and after an ideas generation session (with input from my three kids) the concept for a game, called Paperchase, was born.
The blurb for the game says…
The intergalactic war between the red and blue factions of the biro universe has reached its climax. Each world has sent a stick-figure champion to race in the “Paper chase” for ultimate victory and to decide which colour biro pen teachers should use when marking work. (Get 200 steps ahead to win, collect up to 3 Python power-ups to import antigravity and avoid all other obstacles.)
The PyGame Zero tutorial shows you how to make an animated alien float across the screen. I took this as my starting point and, after several hours of drawing and discarding a huge number of naff-looking stick figures and and taking about 5 minutes on only a few lines of Python code I had this:
(Interesting aside: I estimate I spent about 80% of my time in PyWeek drawing, testing and revising game assets like the animations and objects in the game. Of the remaining 20% of my time, most of it was spent reading PyGame Zero’s excellent documentation to guide me in how to make something or other work. Time spent actually writing Python code was probably only 5% of the total.)
During PyWeek, participants are encouraged to submit diary entries to plot their progress and so others can see how they’re getting on. This was a wonderful experience because participants leave supportive comments on each other’s diary entries and even give user-created “awards” (for instance, I gave one game “Ent of the Year” since the game involved becoming the spirit of a tree). You can read my diary entries here and all the participant’s diary entries are here.
At the end of the week of coding, participants judge each others’ entries and a winner is declared for both individual and team entries. I’m pleased to say I placed a respectable 8th out of 23.
Most importantly for Mu, I was able to try out writing an actual real-life game with it. The experience was remarkably smooth and it was fun to type some code and click the “play” button to immediately see the change take effect. Such a quick turnaround in a write-play-check-change cycle makes coding games lots of fun. I also quickly appreciated the ability to just copy and paste the different sorts of game asset into the right locations thanks to Mu’s shortcuts to the file system.
I’d highly recommend everyone take part in a PyWeek – it’s a fun and supportive community who are friendly to newbies (such as myself). If you do take part, please consider using Mu and PyGame Zero!
How did the game turn out? Here’s a video of me and my thirteen year-old son play-testing the game. The source code can be found here.
Welcome to “Made With Mu”, a blog to celebrate the projects and achievements of users of the Mu Python code editor. Mu is a Python editor for beginner programmers based on extensive feedback given by teachers and learners. The project’s main website can be found at codewith.mu.
If you have a project you’d like celebrated here, use the form on the submit page (also linked from the site’s header) to tell us about it..!
We welcome submissions from anybody, no matter your skill level, project type or background. If you’re thinking, “they probably don’t mean me” then we definitely mean you.
We’re friendly and, if needed, will help make sure your project is presented in the best possible way.
What are you waiting for? Go submit something!
Subscribe via RSS