Clean repository and update .gitignore

- Remove build artifacts from git tracking (build/, dist/, __pycache__/, *.spec)
- Updated .gitignore to properly exclude generated files
- Added old_code/ documentation folder
- Updated sample_data.txt to show new 5-field format
- Exclude user-specific conf/app.conf from tracking
This commit is contained in:
NAME
2026-02-13 23:41:34 +02:00
parent 839828340d
commit 6a11cf3d8d
42 changed files with 2897 additions and 54569 deletions

189
old_code/NEW_FEATURES.md Normal file
View File

@@ -0,0 +1,189 @@
# Label Printing - New Features Guide
## Overview
The label printer now supports:
1. **Multiple Templates** - Choose between OK and NOK labels
2. **Multiple Copies** - Print multiple labels in one operation
## File Format
The monitored file (`check.txt`) now supports an extended format:
```
ARTICLE;NR_ART;SERIAL;TEMPLATE_TYPE;COUNT
```
### Parameters
| Parameter | Position | Description | Values | Default |
|-----------|----------|-------------|--------|---------|
| ARTICLE | 1 | Article/Command number | Any text | Required |
| NR_ART | 2 | Article number | Any text | Required |
| SERIAL | 3 | Serial number | Any text | Required |
| TEMPLATE_TYPE | 4 | Template selection | 0 = OK, 1 = NOK | 0 (OK) |
| COUNT | 5 | Number of copies | 1-100 | 1 |
## Templates
### Template Files
- `conf/label_template_ok.svg` - Template for OK labels (TEMPLATE_TYPE=0)
- `conf/label_template_nok.svg` - Template for NOK labels (TEMPLATE_TYPE=1)
- `conf/label_template.svg` - Default fallback template
### Customizing Templates
Edit the SVG files to customize the layout:
- Both templates use the same variables: `{Article}`, `{NrArt}`, `{Serial}`
- Modify colors, fonts, or layout as needed
- Keep dimensions at 35mm × 25mm (landscape)
## Usage Examples
### Example 1: Print 1 OK Label
```
COM-2024-001;ART-12345;SN-20260213-001;0;1
```
### Example 2: Print 3 OK Labels
```
COM-2024-002;ART-67890;SN-20260213-002;0;3
```
### Example 3: Print 1 NOK Label
```
COM-2024-003;ART-11111;SN-20260213-003;1;1
```
### Example 4: Print 5 NOK Labels
```
COM-2024-004;ART-22222;SN-20260213-004;1;5
```
### Example 5: Backward Compatibility (Old Format)
```
COM-2024-005;ART-33333;SN-20260213-005
```
This will default to OK template with 1 copy.
## Testing
### Quick Test
1. **Start the application**:
```powershell
.\venv\Scripts\python.exe label_printer_gui.py
```
2. **Select your printer** in the GUI
3. **Edit the monitored file** (default: `C:\Users\Public\Documents\check.txt`):
```
TEST-OK;123456;SN-001;0;2
```
4. **Save the file** - The app will automatically:
- Detect OK template (type=0)
- Print 2 copies
5. **Test NOK template**:
```
TEST-NOK;789012;SN-002;1;1
```
### PDF Testing
Use "Microsoft Print to PDF" to test without physical printer:
- Select "Microsoft Print to PDF" in the GUI
- PDFs will be saved to `pdf_backup/` folder
- Check that the correct template was used
## Workflow
```
File Modified
Read Parameters (Article, NrArt, Serial, Template, Count)
Select Template (OK or NOK)
For each copy (1 to Count):
├─ Generate PDF from SVG template
├─ Replace variables {Article}, {NrArt}, {Serial}
├─ Save to pdf_backup/
└─ Print via SumatraPDF
Clear file (write "-")
Show success message
```
## Safety Limits
- **Maximum copies**: 100 per operation
- **Minimum copies**: 1
- Invalid values default to 1 copy
## Troubleshooting
### Template Not Found
- **Symptom**: Message "Using SVG template: conf/label_template.svg"
- **Cause**: `label_template_ok.svg` or `label_template_nok.svg` missing
- **Fix**: Ensure both template files exist in `conf/` folder
### Wrong Template Printed
- **Symptom**: NOK template used when OK expected
- **Cause**: TEMPLATE_TYPE parameter incorrect
- **Fix**: Check 4th parameter is 0 for OK, 1 for NOK
### Only 1 Label Printed
- **Symptom**: COUNT parameter ignored
- **Cause**: Invalid COUNT value or missing parameter
- **Fix**: Ensure 5th parameter is a number between 1-100
## Technical Details
### File Parsing
The system tries:
1. **Semicolon format**: `value1;value2;value3;value4;value5`
2. **Key=value format** (fallback):
```
article=COM-2024-001
nr_art=ART-12345
serial=SN-001
template=0
count=3
```
### Multiple Copy Handling
- Each label is printed sequentially
- 0.5 second delay between copies
- Progress shown in GUI for multiple copies
- All copies use the same PDF template
### Backward Compatibility
Old format (3 parameters) still works:
```
ARTICLE;NR_ART;SERIAL
```
Automatically uses: OK template, 1 copy
## Log Files
Print actions are logged to `logs/print_log_YYYYMMDD.csv`:
- Date/Time
- Article, NrArt, Serial
- Printer name
- PDF filename
- Template used
- Number of copies
- Success/Failure status
---
**Version**: February 2026
**Compatible with**: Citizen CTS-310, Zebra ZD420/ZD421