1. On your Raspberry Pi, create the folder that will host your project.
Open the terminal, navigate to the folder where your projects are stored, and create a new folder (I’ll call it “MyCustomWidgets”, but you can name it whatever you like):
mkdir "MyCustomWidgets"
2. Create your virtual environment
Go to your project folder:
cd "MyCustomWidgets"
and choose a name for your environment (I’ll call it raspc_env, but you can name it whatever you like). This will create a new folder called “raspc_env.”
python3 -m venv raspc_env
3. Activate the virtual environment
source raspc_env/bin/activate
You’ll notice your terminal prompt change to show the environment name (e.g., (raspc_env)$). This means you’re in the virtual environment!
4. Add your custom script
Create your Python scripts (which we’ll call myscript.py in our example) in your “MyCustomWidgets” project folder.
The script will read the sensor and print at least one result. This result will be captured by RaspController and displayed.
The result must be placed within the numbered <result></result> tags. Up to 9 results can be printed (example: <result9>123.4</result9>).
Do not use infinite loops (while True) in your script. The workflow should be:
a. start of the script;
b. read data from the sensor (and process it if necessary);
c. print the results; example: print(result1)...
d. end of the script.
If you need to display constantly updated results, use the app’s “recursive” function, which will:
– run your script
– display the results
– wait a second
– rerun the script (RaspController will loop until the app is running).
If something is printed from the script without the <result> tags, the app will display a dialog box with the text; this is useful for reporting errors:
print("This is my error text")
5. Deactivate the virtual environment
When you’re finished working, simply type:
deactivate
The terminal prompt will return to normal.
Warning: Python virtual environments (the raspc_env folder) cannot be moved or renamed after they are created.
If the absolute path changes because the parent folders have been renamed or moved, you must delete the virtual environment with:
rm -rf raspc_env
and create a new, clean environment:
python3 -m venv raspc_env



