VSCode editor

In this tutorial we explain how to run BornAgain Python examples in a convenient manner using the VSCode editor. This is a community driven, lightweighted and open-source editor from Microsoft, which provides code highlighting for many languages and can be extremely handy in any kind of script-related and code-related activity.

At this point we assume that the user has already installed BornAgain and a Python distribution as explained in Python installation section.

Download and install VSCode

Download the editor from official website.

Download the installer

Run the installer

Add the BornAgain examples to VSCode

Start VSCode and you will find yourself on the welcome screen.

Add the folder with the BornAgain Python examples to the workspace by clicking Add workspace folder as shown in the screenshot below.

Choose the directory with the BornAgain Python examples at C:/BornAgain-1.19.0/Examples. If you open any example, VSCode will require you to configure the Python interpreter to use. In the screenshot below, VSCode is complaining that no Python interpreter was selected and also suggests to install the so-called pylint plugin for a better code development experience.

Click on Select Python Interpreter and select the interpreter you have installed previously. Install pylint too. On the screenshot below VSCode is fully configured and ready for work.

Finally you can run an example using the right mouse button.

The script will be executed in a terminal embedded in VSCode and a scattering image will appear on the screen after simulation has completed.

Now you can try to run other BornAgain Python examples and start your exciting journey in Python scripting with BornAgain!