Hi @ashio.
You can use the same "bridge" interface in Python scripts that run directly on the standard Linux machine of the UNO Q. I'll provide instructions you can follow to do that:
A. Open a Terminal
This demo will use command line invocations run on the UNO Q's Linux machine. For this reason, you first need to open a command line terminal on the Linux machine.
If you are single-board computer (SBC) mode, open the terminal via the desktop menu.
If you are using the board in PC hosted mode, you can open a terminal using Android Debug Bridge (ADB) via the USB connection to the board, by following the instructions here:
https://docs.arduino.cc/tutorials/uno-q/adb/
Or open a terminal using Secure Shell (SSH) via the network connection to the board, by following the instructions here:
https://docs.arduino.cc/tutorials/uno-q/ssh/
B. Create Virtual Python Environment
When you are working with Python scripts on the standard Linux machine of the UNO Q, it is a good idea to create a virtual environment for the project. This ensures the installed Python package dependencies of the script are isolated from the global environment, both to avoid the possibility of their presence affecting other Python scripts, and so that any Python scripts installed in the global environment can't interfere with the script you are working with.
I would normally recommend using my favorite tool, Poetry for this purpose. However, the tool chosen by the developers of the Arduino App framework is uv. It makes sense to utilize the same tool used in the App's container. Furthermore, I believe this is actually more lightweight than Poetry, and thus well suited for use on the UNO Q where we must conserve our use of computing resources.
So let's start by installing uv:
https://docs.astral.sh/uv/getting-started/installation/
I did it by running the following command from the terminal:
curl -LsSf https://astral.sh/uv/install.sh | sh && source $HOME/.local/bin/env
Now create a uv project by running the following command from the terminal:
uv init --bare --no-package ~/bridgetest && cd ~/bridgetest
C. Install Project Dependencies
Now we need to install the arduino Python package that provides the arduino.app_utils module, which facilitates communication between the Python script running on the UNO Q's Linux machine with the sketch program running on the board's microcontroller via the "bridge" interface. We can use the uv add command to install that package into the virtual environment for our "bridgetest" project. Normally we can do this by simply specifying the package name as the argument to the command. However, Arduino has not published the arduino package to the Python package registry, so that is not possible. For this reason, we must instead install it from the wheel file published by Arduino on the "Releases" page of the arduino/app-bricks-py GitHub repository. Currently the latest release of the package is version 0.8.0, which we can install into the virtual environment by using this command:
uv add https://github.com/arduino/app-bricks-py/releases/download/release%2F0.8.0/arduino_app_bricks-0.8.0-py3-none-any.whl
It is also necessary to install some standard packages that are dependencies of the arduino package. These are in the Python package registry, so can be installed in the ordinary manner:
uv add numpy watchdog
Now we can use the arduino.app_utils module in the Python script running directly on the standard Linux machine, just the same as we would do in the Python script component of an Arduino App.
D. Create Project Code
For the purpose of this demonstration, let's just use the existing Python script and Arduino sketch from the simple "Blink LED" example App:
wget --directory-prefix=python https://raw.githubusercontent.com/arduino/app-bricks-examples/refs/tags/0.8.0/examples/blink/python/main.py && wget --directory-prefix=sketch https://raw.githubusercontent.com/arduino/app-bricks-examples/refs/tags/0.8.0/examples/blink/sketch/sketch.ino https://raw.githubusercontent.com/arduino/app-bricks-examples/refs/tags/0.8.0/examples/blink/sketch/sketch.yaml
E. Run Project
Since we are using the bridge, we must have an appropriate sketch program running on the microcontroller, in addition to the Python script on the Linux machine. So we should start by compiling and uploading the sketch, which we obtained from the "Blink LED" example App.
You can use Arduino IDE to upload sketches to your UNO Q board if you like. However, for the sake of simplicity in this demo, I'll use the Arduino CLI command line tool, which is preinstalled on the UNO Q's Linux machine:
arduino-cli compile --fqbn arduino:zephyr:unoq --upload sketch/
Now let's run the Python script:
uv run python/main.py
You should now see the built-in LED on the UNO Q board blinking at 0.5 Hz.