1
0
Fork
You've already forked ComponentLabels
0
Sticky label generator for zip bags with electronic components.
  • Python 68.4%
  • JavaScript 27.1%
  • CSS 4.2%
  • HTML 0.3%
2026年04月28日 18:11:11 +02:00
scripts Remove redundant check 2025年07月17日 18:06:06 +10:00
src Increase spacing between color bands 2026年04月28日 18:11:00 +02:00
tests Increase spacing between color bands 2026年04月28日 18:11:00 +02:00
.gitignore Add power and tolerance values to resistor 2026年04月24日 22:46:27 +02:00
.mypy.ini Fix missing mypy errors 2023年02月24日 18:08:04 +01:00
AGENTS.md Update AGENTS.md 2026年04月28日 18:11:11 +02:00
componentlabels.webp Moved to Codeberg 2026年02月17日 22:14:41 +01:00
components.yaml Add new paper config 2026年04月28日 18:10:48 +02:00
Example.pdf Implemented springs and threaded inserts 2024年07月25日 18:53:08 +02:00
Example.png Add example of my version and updated readme 2023年03月15日 12:51:37 -07:00
LabelGenerator.py Add validation for components.yaml 2026年04月22日 12:17:33 +02:00
LICENSE Initial commit 2020年09月20日 19:25:19 +02:00
paper.yaml Add new paper config 2026年04月28日 18:10:48 +02:00
README.md WIP: building web service 2026年04月27日 21:08:40 +02:00
requirements-dev.txt Fixed PyPDF version 2025年08月19日 12:16:29 +02:00
requirements.txt WIP: building web service 2026年04月27日 21:08:40 +02:00
Roboto-Bold.ttf Add Roboto-Bold as fallback option 2021年06月19日 11:35:34 +02:00

ComponentLabels

This script generates labels for zip bags with all sorts of electronic or mechanical components.

It is primarily meant for these labels (70x25.4 mm) and these 8x12 cm zip bags. However, the generator script also supports AVERY 5260, AVERY L7157 and AVERY J8157 labels.

Some examples of ComponentLabels

Supported components

  • Resistors (resistance, 3 & 4 digit SMD code, EIA-96 code and 3 & 4 band color codes)
  • Capacitors (capacitance, 3 digit SMD code, EIA-198 code and 3 band color code (yes, those appear to actually exist))
  • Diodes & Schottky diodes (name, forward voltage/current, reverse voltage)
  • Zener diodes (name, reverse voltage/current, forward voltage)
  • LEDs (diameter/name, forward voltage/current, wavelength)
  • PNP/NPN BJT (name, base-emittor voltage, collector-emittor voltage/current)
  • P/N-channel MOSFET (name, gate-source voltage, drain current, drain-source voltage)
  • Square/Hexagonal nuts (thread type, thickness, width and diameter)
  • Washers (thread type, thickness, diameter)
  • Recessed/Round-head/Flat-head screws (thread type, head width, head height and screw length)
  • Threaded inserts for 3D prints (thread type, diameter and length)
  • Compression/Extension springs (diameter and length)

Usage

Install

On Linux

Make sure that python3 is installed

sudo apt install python3

Then install ComponentLabels

git clone --depth=1 https://codeberg.org/prochazkaml/ComponentLabels.git
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Running

  • Edit components.yaml to choose which components should be rendered.
  • Edit paper.yaml to add or adjust paper definitions if needed.
source .venv/bin/activate
python LabelGenerator.py

This will generate the PDF specified by output_filename in components.yaml.

Command line options

  • python LabelGenerator.py --components components.yaml --paper paper.yaml
  • python LabelGenerator.py --layout AVERY_5260 --output /tmp/labels.pdf
  • python LabelGenerator.py --components custom-components.yaml --paper custom-paper.yaml --layout VYSOCINA --output CustomLabels.pdf

Available arguments:

  • --components: path to the component configuration YAML file
  • --paper: path to the paper configuration YAML file
  • --layout: override the layout value from components.yaml
  • --output: override the output_filename value from components.yaml

Web UI

Run the FastAPI server and open the single-page editor in your browser:

source .venv/bin/activate
python -m src.server

Then open http://127.0.0.1:8000.

The web UI supports:

  • editing the same component configuration model used by components.yaml
  • saving in-progress work in IndexedDB
  • generating ComponentLabels.pdf
  • downloading the current form state as components.yaml
  • resetting the form and deleting the IndexedDB database

Tests

Run the unit tests with Python's built-in unittest runner:

source .venv/bin/activate
python -m unittest discover -s tests -p 'test_*.py' -v

Label alignment helper script

A helper script is available to assist with creating new label definitions.

If you scan a blank sheet of labels of your choice that you want to create definitions for, this helper script can overlay the scanned blank page (with the seams between the individual labels visible) with your generated labels. This way, you can verify that your new label definitions are correct without the need to print anything.

For example: ./scripts/check_alignment.py --template scanned_labels.pdf --labels ComponentLabels.pdf --output combined.pdf will produce a file named combined.pdf that will have the scanned labels as a background for each page and the generated labels overlayed on top.

Of course, this script assumes that your scanner is properly aligned and set to the same page size as your generated labels.

Credits

This is forked from https://github.com/securelyfitz/ResistorLabels, which is in turn a fork of https://github.com/Finomnis/ResistorLabels.

The original is based on an idea from Zach Poff. I liked the design of securelyfitz's forked labels, I just needed to implement more than resistors.

For more details on how to use these labels, visit Zach's website.