Skip to content

Using Basthon-Console ​

Finding your way around the interface ​

The interface of Basthon-Console: the editor on the left, the console on the right

The editor, where you write your script, is on the left; the console, where it runs, is on the right. The help button at the bottom right leads to this documentation.

ButtonAction
RunRuns the content of the editor in the console.
OpenOpens a script in the editor, imports a module or loads an extra file. See the sections Saving and opening a script, Using extra files and Importing your own module.
DownloadDownloads the content of the editor into a file. See the section Saving and opening a script.
ShareShares the current content of the editor through a URL. See the section Sharing a script.
Back to a previous versionGoes back to a previous version of the script. See the section Going back to a previous version.
Hide the editorHides the editor (console only). A button then appears below the console to show the editor and the console again.
RestartReset: the console and the graphical output are cleared and the kernel (the language's interpreter) is restarted.
ConsoleShows the console (instead of the graphical output).
Graphical viewShows the graphical output (instead of the console), to see a Turtle or Matplotlib drawing, etc.
Console and graphical viewShows the console and the graphical output, one above the other.
ThemeSwitches the display between light and dark modes.
SwapSwaps the places of the console and of the editor. When only one of them is shown, shows the other one instead.

Info

Some users expect a window to open with the graphical output (for Turtle or Matplotlib for instance). It does not. Show it with the graphical view button (which blinks when a new drawing is available), or show the console and the graphical output together with the console and graphical view button.

Astuce

It can be handy to enlarge or reduce the font of the editor and of the console. Use Ctrl+wheel or Ctrl++.

Astuce

The dark mode (the default) is soothing for the eyes but does not suit a video projector, since it has little contrast. Switch to the light mode with the theme button.

Info

The appearance you chose (theme, layout of the panels) and the content of the editor are kept by your browser: you find Basthon in the state you left it in.

Using the editor ​

The editor has syntax highlighting and completion. It is used as usual, with many shortcuts. In particular, Ctrl+Z undoes an action, Ctrl+A selects the whole content, Ctrl+F searches, Ctrl+, changes the settings of the editor and Ctrl+S downloads the script. The functions and variables declared in the editor are available in the console, and conversely.

Using the console ​

The console is used like the usual Python interpreter (or that of the chosen language, see Other languages). The Enter key runs a statement. An incomplete statement (after def f(): or for i in range(3): for instance) goes on to the next line, marked with ...: an empty line ends it and runs it. The functions and variables declared in the editor are available in the console, and conversely.

KeysAction
↑ / ↓browse the history of statements
Tabcomplete the current name (or indent at the start of a line)
Ctrl+A / Ctrl+Ego to the start / the end of the line (as Home / End)
Ctrl+← / Ctrl+→go to the previous / next word
Ctrl+U / Ctrl+Kerase up to the start / up to the end of the line
Ctrl+Werase the previous word
Ctrl+Ccopy the selection or, with no selection, drop the current line

Astuce

A program that runs too long (an infinite loop for instance) can be stopped by restarting the kernel with the restart button.

Saving and opening a script ​

To save the content of the editor into a *.py file, use the download button (or Ctrl+S).

To load the content of a *.py file into the editor, use the open button and choose "Charger dans l'éditeur" (load into the editor). This button also loads extra resources such as text files, images or even Python modules: see the sections Using extra files and Importing your own module.

Going back to a previous version ​

Basthon keeps the last versions of your script (at each run and when the page is closed). The back to a previous version button lets you pick one of them, by its date, to load it back into the editor.

Astuce

If the page was closed while a program was running (an infinite loop for instance), Basthon notices it at the next load and offers to choose the backup to resume from.

Sharing a script and using files ​

The share button creates a link that holds the script. To share a script put on the web, with its extra files and modules, see Sharing an activity and its link generator.

The open button also loads extra files (images, data…) and modules: see Extra files and modules.