toga-barcode-scanner 📷📦
A cross-platform, native camera barcode and QR code scanner hardware plugin for the BeeWare (Toga) ecosystem.
Offloads computer vision recognition to native operating system frameworks (AVFoundation on iOS, CameraX + Google ML Kit on Android) without blocking the Python GIL or UI rendering, providing instant scanning throughput with seamless mock fallbacks for desktop development.
🚀 Quick Start
Installation
pip install toga-barcode-scanner
For iOS development environments:
pip install "toga-barcode-scanner[ios]"
Usage Example
import toga
from toga_barcode_scanner import BarcodeScanner, BarcodeFormat, BarcodeResult, ScanMode
class SodaTryMobileApp(toga.App):
def startup(self):
# 1. Initialize the scanner instance
self.scanner = BarcodeScanner(
app=self,
on_barcode=self.handle_barcode,
on_error=self.handle_error,
formats=[BarcodeFormat.UPC_A, BarcodeFormat.EAN_13, BarcodeFormat.QR_CODE],
scan_mode=ScanMode.SINGLE_SHOT,
beep_on_scan=True,
debounce_ms=300,
)
# 2. Add trigger button
self.main_window = toga.MainWindow(title="Soda Catalog Scanner")
self.main_window.content = toga.Button(
"Scan Soda Barcode",
on_press=lambda widget: self.scanner.start_scan(parent_window=self.main_window)
)
self.main_window.show()
def handle_barcode(self, result: BarcodeResult):
print(f"Scanned {result.format.value}: {result.raw_value}")
# Process product lookup...
self.main_window.info_dialog("Scan Result", f"Found barcode: {result.raw_value}")
def handle_error(self, error_message: str):
self.main_window.error_dialog("Camera Error", error_message)
def main():
return SodaTryMobileApp("SodaTry", "com.sodatry.mobile")
if __name__ == "__main__":
main().main_loop()
📱 Platform Support
| Platform | Underlying Engine | Direct Hardware Acceleration |
|---|---|---|
| iOS | AVFoundation + UIKit via rubicon-objc |
✅ Native Metal / Apple Neural Engine |
| Android | CameraX + Google ML Kit Barcode Scanning |
✅ Native GPU / Android NNAPI |
| Desktop (macOS / Linux / Windows) | Dummy Mock / Synthetic Event Injection | 🧪 Headless CI & Mock Dialogs |
🛠️ Briefcase Packaging Configuration
When packaging your BeeWare application using briefcase, configure target platform permissions and dependencies in pyproject.toml:
iOS Configuration (NSCameraUsageDescription)
In your app's pyproject.toml:
[tool.briefcase.app.myapp.iOS]
info_plist_extra = { "NSCameraUsageDescription" = "Camera access is required to scan product barcodes." }
Android Configuration (Permissions & Gradle Dependencies)
In your app's pyproject.toml:
[tool.briefcase.app.myapp.android]
permissions = [
"android.permission.CAMERA",
]
features = [
"android.hardware.camera",
]
build_gradle_dependencies = [
"androidx.camera:camera-core:1.3.1",
"androidx.camera:camera-camera2:1.3.1",
"androidx.camera:camera-lifecycle:1.3.1",
"androidx.camera:camera-view:1.3.1",
"com.google.mlkit:barcode-scanning:17.2.0",
]
🧪 Testing & Synthetic Event Injection
The dummy backend allows programmatic simulation of barcode events for headless CI and desktop testing without physical cameras:
from toga_barcode_scanner import BarcodeScanner, BarcodeFormat
scanner = BarcodeScanner(
on_barcode=lambda res: print(f"Received {res.raw_value}"),
backend="dummy",
)
scanner.start_scan()
# Programmatically inject a barcode scan event
scanner._inject_barcode("012000000133", BarcodeFormat.UPC_A)
📖 Documentation
- Technical Architecture & Design Specification (DESIGN.md)
- Milestones & Development Plan (PLAN.md)
- Contribution Guidelines (CONTRIBUTING.md)
- Release History (CHANGELOG.md)
📄 License
Distributed under the MIT License. See LICENSE for details.
Metadata
Release files for toga-barcode-scanner 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| toga_barcode_scanner-0.1.2.tar.gz | 21.1 kB | With provenance | Details for toga_barcode_scanner-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| toga_barcode_scanner-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for toga_barcode_scanner-0.1.2-py3-none-any.whl |
Total release size: 40.6 kB
Release files / toga_barcode_scanner-0.1.2.tar.gz
| Download URL | toga_barcode_scanner-0.1.2.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ffa81222bc78d1bfef592776ec1ebf949d7daa733bc8d66b4b1fe6fe1476d0c3
|
|
BLAKE2b-256 checksum How to use checksums |
bfc7c59ea8885794598aa383c73b83ca632cfc33a57b0a03c560828d2443ac5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logRelease files / toga_barcode_scanner-0.1.2-py3-none-any.whl
| Download URL | toga_barcode_scanner-0.1.2-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
155dc52c5bfa28adafdabfc5cd0f227d0dfc6fa5c31c5132f869785112dc137e
|
|
BLAKE2b-256 checksum How to use checksums |
61676b46d8f99df3a57048ca1e3e9a75315609ee42e12e3d781e1050516c743e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logSecurity for toga-barcode-scanner 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for toga_barcode_scanner-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.