- Python 68.4%
- JavaScript 27.1%
- CSS 4.2%
- HTML 0.3%
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.yamlto choose which components should be rendered. - Edit
paper.yamlto 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.yamlpython LabelGenerator.py --layout AVERY_5260 --output /tmp/labels.pdfpython 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 thelayoutvalue fromcomponents.yaml--output: override theoutput_filenamevalue fromcomponents.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.