A minimal Horos/OsiriX plugin template that runs a bundled Python script from the Image Filters menu. It is meant to be a small, working starting point for collaborators who want Python inside a plugin without first learning a larger framework.
- Working minimal template - Starting point for building custom plugins.
Runs python_script/main.py, writes Hello world!! to the console, and shows an in-app success alert.
- A real build target for both Horos and OsiriX via
./build.sh horos|osirix|both - A bundled Python entrypoint at
Python-Runner-Horos-Plugin/python_script/main.py - A concrete first-run path:
Plugins > Image Filters > PythonRunnerHorosPlugin > Run Python Script - A known-good expected result:
- console log:
Hello world!! - app alert:
Python script ran. Search the Xcode console for a 'Hello world!!' message.
- console log:
git clone https://github.com/ThalesMMS/Python-Runner-OsiriX-Horos-Plugin.git
cd Python-Runner-OsiriX-Horos-Plugin
# Build for your platform
./build.sh horos # or: ./build.sh osirix
# Install and sign the plugin
unzip -o Releases/Horos/PythonRunnerHorosPlugin.osirixplugin.zip -d "$HOME/Library/Application Support/Horos/Plugins/"
codesign --force --deep --sign - "$HOME/Library/Application Support/Horos/Plugins/PythonRunnerHorosPlugin.osirixplugin"If you are using OsiriX, swap horos/Horos for osirix/OsiriX in the commands above.
Then:
- Restart Horos/OsiriX
- Open any study and bring a 2D viewer window to the front
- Run
Plugins > Image Filters > PythonRunnerHorosPlugin > Run Python Script - Confirm you get the success alert and
Hello world!!in the console
Complete. You now have a working plugin template. Modify python_script/main.py to add your own functionality.
This plugin provides:
- Python Integration: Execute Python scripts directly from Horos/OsiriX
- Dual-Platform Support: Single codebase for both Horos and OsiriX
- Clean Template: Minimal working example you can extend
- Simple Workflow: Menu item → Python script → Console output → Alert
- Open a study and make a 2D viewer window active before using the menu item
- Menu item:
Plugins > Image Filters > PythonRunnerHorosPlugin > Run Python Script - Action: runs
python_script/main.pyand prints to the console - UI: shows a success alert after the script finishes
- No DICOM export/import, no configuration UI
- macOS: 11.0 or later
- Xcode: 15 or 16+ for building the plugin
- Python: Python 3 available via
python3in PATH - Apple Silicon: Supported on M1/M2/M3 Macs
- Both Rosetta and native arm64 builds supported
- No special configuration needed
- Same build process for Intel and Apple Silicon
- For Horos: Horos 4.0 or later recommended
- For OsiriX: OsiriX MD 12.0 or later recommended
The automated build script handles all configuration switching and compilation:
# Build for Horos only
./build.sh horos
# Build for OsiriX only
./build.sh osirix
# Build for both platforms
./build.sh bothBuilt plugins are placed in:
Releases/Horos/PythonRunnerHorosPlugin.osirixplugin.zipReleases/OsiriX/PythonRunnerHorosPlugin.osirixplugin.zip
The build script automatically:
- Switches between platform-specific Xcode configurations
- Builds the plugin with the correct framework
- Archives and zips the plugin for distribution
If you prefer to build manually in Xcode:
- Open
PythonRunnerHorosPlugin.xcodeproj - Ensure the correct platform configuration is active (see
build.shfor details) - Build the project (⌘B)
- The plugin will be in the build output directory
# Set the Horos plugins directory
PLUGIN_DST="$HOME/Library/Application Support/Horos/Plugins/"
# Extract the plugin
unzip -o Releases/Horos/PythonRunnerHorosPlugin.osirixplugin.zip -d "$PLUGIN_DST"
# Sign the plugin (required on Apple Silicon and modern macOS)
codesign --force --deep --sign - "$PLUGIN_DST/PythonRunnerHorosPlugin.osirixplugin"# Set the OsiriX plugins directory
PLUGIN_DST="$HOME/Library/Application Support/OsiriX/Plugins/"
# Extract the plugin
unzip -o Releases/OsiriX/PythonRunnerHorosPlugin.osirixplugin.zip -d "$PLUGIN_DST"
# Sign the plugin (required on Apple Silicon and modern macOS)
codesign --force --deep --sign - "$PLUGIN_DST/PythonRunnerHorosPlugin.osirixplugin"- Restart Horos/OsiriX - The application must be restarted to load the new plugin
- Verify Installation - Check
Plugins > Plugin Managerto confirm the plugin loaded - Check Console - If the plugin doesn't appear, check Console.app for error messages
- Open a study and bring a 2D viewer window to the front (Image Filters are disabled without an active viewer).
- Choose
Run Python Scriptfrom the plugin menu. - Check the console for
Hello world!!frompython_script/main.py. - A success alert appears inside Horos/OsiriX.
Python-Runner-Horos-Plugin/
├── build.sh # Build script for both platforms
├── Releases/
│ ├── Horos/ # Horos build output
│ └── OsiriX/ # OsiriX build output
└── Python-Runner-Horos-Plugin/ # Plugin sources
├── Plugin.swift # Main plugin code
├── Info.plist # Plugin metadata
├── python_script/ # Bundled Python entrypoint
│ └── main.py
├── Horos.framework/ # Horos SDK
├── OsiriXAPI.framework/ # OsiriX SDK
└── PythonRunnerHorosPlugin.xcodeproj/
├── project.pbxproj # Active project config
├── project_Horos.pbxproj # Horos-specific config
└── project_OsiriX.pbxproj # OsiriX-specific config
The plugin supports both Horos and OsiriX through platform-specific configuration files:
project_Horos.pbxproj/project_OsiriX.pbxproj- Xcode project configs*-Bridging-Header_Horos.h/*-Bridging-Header_OsiriX.h- Swift bridging headers
The build.sh script automatically switches between configurations before building.
MIT. See LICENSE.