Skip to main content

A barcode scanner component for NiceGUI applications

Project description

NiceGUI barcode scanner app

This project demonstrates how to create a barcode scanner using the ZXing library wrapped in a NiceGUI custom Vue component. Based on this discussion, and inspired by the custom vue component example.

Usage

Install the package from PyPI:

pip install nicegui nicegui-scanner

Basic Example

Create a simple barcode scanner app (save as scanner_app.py):

from nicegui import ui
from nicegui_scanner import BarcodeScanner

def on_scan(event):
    barcode = event.args
    ui.notify(f"Scanned: {barcode}")

ui.html("<h1>My Barcode Scanner</h1>")

# Create scanner with custom styling  
scanner = BarcodeScanner(on_scan=on_scan).style(
    "width: 400px; height: 300px; border: 2px solid #007acc;"
)

# Add controls
with ui.row():
    ui.button("Start", on_click=scanner.start_scanning)
    ui.button("Stop", on_click=scanner.stop_scanning)

ui.run()

Then run: python scanner_app.py

Note: The ZXing JavaScript library is automatically bundled with the package - no additional setup required!

Features

  • Easy Integration: Drop-in component for NiceGUI apps
  • Camera Selection: Automatic camera detection with settings UI
  • Flexible Styling: Use standard CSS via .style() method
  • Multiple Formats: Supports QR codes, barcodes, and more via ZXing
  • Page Context: Works in both ui.run() and @ui.page() contexts

Examples

See the examples/ directory for:

  • app.py - Multiple scanner configurations
  • page_example.py - Usage with NiceGUI pages

Development

To develop this component, install dependencies and run the hello world app:

npm install  # Install ZXing library
uv sync      # Install Python dependencies
make dev     # Run example app

This will start the example app on http://localhost:3001 with multiple scanner demos.

Questions

  • How to bundle node module with NiceGUI elements?
  • What is the nicegui way of handling errors from vue components?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nicegui_scanner-0.1.3.tar.gz (317.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nicegui_scanner-0.1.3-py3-none-any.whl (106.0 kB view details)

Uploaded Python 3

File details

Details for the file nicegui_scanner-0.1.3.tar.gz.

File metadata

  • Download URL: nicegui_scanner-0.1.3.tar.gz
  • Upload date:
  • Size: 317.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nicegui_scanner-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c58091988703c2a3ec744f8abb4d31f92d46f45c001dcc2bd26cda646a422280
MD5 729fb71883d60a3f3791478f9e143b60
BLAKE2b-256 dc2a459ab6342c8e83608f6c88c2c673308c76716e30b7e9fcd61356d71e86f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for nicegui_scanner-0.1.3.tar.gz:

Publisher: release.yml on serraict/nicegui-scanner-app

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nicegui_scanner-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: nicegui_scanner-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 106.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nicegui_scanner-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2fbad8c3d5bea8516e553a8c1bba58c143dcaee82ca91ba7879341614711af0a
MD5 c3442386cf787c31375e3dbe49fd6212
BLAKE2b-256 2b88cd3fcc8e7f5de9c66ba2905b3c946515bb473a529af729d0b58d47586183

See more details on using hashes here.

Provenance

The following attestation bundles were made for nicegui_scanner-0.1.3-py3-none-any.whl:

Publisher: release.yml on serraict/nicegui-scanner-app

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page