Use this library to develop your python programs for the Calliope Mini using a state-of-the-art python IDE such as Visual Studio Code on your computer.
This library only helps by providing documentation, type annotations and function signatures. It does not contain a simulator/emulator and it does not allow to transfer the developed code to the Calliope Mini.
- Install the
ms-python.pythonextension. - Create a
virtual environment,
via
python -m venv <name>and activate it. Note: Make sure to install this only in a local virtual environment (and not system-wide) as some libraries overwrite "system" libraries and thus make scripts that are not intended to run on the Calliope Mini fail. pip install calliope-mini-stubsto get this package installed.- Select the correct python (e.g. if you
pip installedinto a virtual environment, chose the python from there).
Now you can create a file and begin it with from calliope_mini import display
and upon typing display.sh you should see display.show as proposal and if
you select it the help text for display.show.
To make more of the extension:
- Enable Checkers
pylintandmypy-- see python linting.
-
Create a virtual environment
% python3 -m venv --system-site-packages venv -
Activate it (
python,pip, etc will be found in this directory from now on)% source ./venv/bin/activate -
Verify, that you are using this virtual envirnonment --
which python3should generate something like this% which python3 <path where you work>/venv/bin/python3 -
Install this package
% python3 -m pip install --upgrade calliope-mini-stubs Looking in indexes: .... Collecting calliope-mini-stubs Downloading https://.... Installing collected packages: calliope-mini-stubs Successfully installed calliope-mini-stubs-<version> -
Launch Visual Studio Code
% code . -
Create a new python file, for example
hello_world.py. -
Make sure, that the correct interpreter is used. On the lower left corner of VSCode you should see the python from
venvselected:If this is not the correct one, then select the right interpreter. To do so:
-
In your python file, start typing, e.g.
import calliope_mini. During typing, you should already getcalliope_miniproposed. IntelliSense allows VSCode to give you hints on what objects/methods/... you can select in this placeand VSCode can directly display the documentation for the method you currently use (e.g. the function signature and a human readable description)
This package is licensed under MIT license.
See the LICENSE file.
It uses code from the package pseudo-microbit which is also MIT licensed
(same as this package) with the copyright notice
Copyright (c) 2013-2016 The MicroPython-on-micro:bit Developers, as listed
in the accompanying AUTHORS file
Generatlly, stubs should be distributed in the form of .pyi files -- one
.pyi with documentation/typing informatino for each .py file.
PEP 484
describes, how the .pyi files should look like.
PEP 561 describes, how to distribute them:
- The package needs to be named
foopkg-stubsfor packagefoopkg - A file
py.typedmust be installed in the top-level of the package.
- pylint does not recognize
__init__.pyifiles: pylint-dev/pylint#2873 This way, if you declare modules with interfaces only, pylint will display the errorundefined variable ...orno ... in module .... (vscode will correctly show the methods/docstrings/..., though!) -> Solution: Use.pyfiles instead of.pyifiles. - static values such as
Image.HAPPYare neither autocompleted nor properly recognized as type (i.e.aina = Image.HEARTis not detected asImage(orMicroBitImage)). IfImagewere an instance it would work... See the question how to get that working.



