From 7f88dcaab55df671293a112a899e73a2cead26fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 27 Dec 2021 20:52:01 +0100 Subject: [PATCH] Add example printing from CSV --- .vscode/launch.json | 12 +++++++++++- README.MD | 3 +++ labels.csv | 10 ++++++++++ print_labels_from_csv.py | 21 +++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 labels.csv create mode 100644 print_labels_from_csv.py diff --git a/.vscode/launch.json b/.vscode/launch.json index 1a91bf3..4e3b52e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,13 +4,23 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { - "name": "Python: Current File", + "name": "Python: Example Print", "type": "python", "request": "launch", "program": "${workspaceFolder}/generate_label_example.py", "console": "integratedTerminal", "args": [] + }, + { + "name": "Python: Print CSV", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/print_labels_from_csv.py", + "console": "integratedTerminal", + "args": [] } ] + } \ No newline at end of file diff --git a/README.MD b/README.MD index f12c453..d57f7aa 100644 --- a/README.MD +++ b/README.MD @@ -1,3 +1,6 @@ +# Prerequisites +- This project requires the brother_ql binary from the ``brother_ql`` project to be in the PATH. + # License This project is licensed under the GPLv2 license. diff --git a/labels.csv b/labels.csv new file mode 100644 index 0000000..6c6bafd --- /dev/null +++ b/labels.csv @@ -0,0 +1,10 @@ +Heading,Line1,Line2,Cut +100n 10%,0603 X7R 10V,AVX, +100n 10%,0603 X7R 10V,Kemet, +100n 10%,0603 X7R 10V,AVX, +100n 10%,0805 X7R 10V,Taiyo Yuden, +100n 10%,0805 X7R 10V,TKK, +100n 20%,1206 X7R 25V,Murata, +220n 20%,0805 X5R 100V,Murata, +120n 10%,1206 X7R 10V,Samsung,1 + diff --git a/print_labels_from_csv.py b/print_labels_from_csv.py new file mode 100644 index 0000000..e3b54dd --- /dev/null +++ b/print_labels_from_csv.py @@ -0,0 +1,21 @@ +import pandas as pd +import shimatta_label.label_image as li +import shimatta_label.brother_ql_wrapper as ql_wrapper +import os + +medir = os.path.dirname(__file__) +example_data_path = os.path.join(medir, 'labels.csv') + +df = pd.read_csv(example_data_path) + +printer = ql_wrapper.BrotherQlPrinter(model='QL-800', printer_connection='usb://0x04f9:0x209b') + +for _, row in df.iterrows(): + label = li.MiceToiletLabel() + label.put_text(row['Heading'], row['Line1'], row['Line2']) + file_path = label.save() + cut = False + if row['Cut'] == 1: + cut = True + printer.print_image(file_path, cut = cut, rotation=270) + os.remove(file_path) \ No newline at end of file