diff --git a/dibbler/lib/barcode_helpers.py b/dibbler/lib/barcode_helpers.py index bf698e0..4f07e27 100644 --- a/dibbler/lib/barcode_helpers.py +++ b/dibbler/lib/barcode_helpers.py @@ -2,7 +2,7 @@ import os from PIL import ImageFont from barcode.writer import ImageWriter, mm2px -from brother_ql.devicedependent import label_type_specs +from brother_ql.labels import ALL_LABELS def px2mm(px, dpi=300): @@ -12,14 +12,15 @@ def px2mm(px, dpi=300): class BrotherLabelWriter(ImageWriter): def __init__(self, typ="62", max_height=350, rot=False, text=None): super(BrotherLabelWriter, self).__init__() - assert typ in label_type_specs + label = next([l for l in ALL_LABELS if l.identifier == typ]) + assert label is not None self.rot = rot if self.rot: - self._h, self._w = label_type_specs[typ]["dots_printable"] + self._h, self._w = label.dots_printable if self._w == 0 or self._w > max_height: self._w = min(max_height, self._h / 2) else: - self._w, self._h = label_type_specs[typ]["dots_printable"] + self._w, self._h = label.dots_printable if self._h == 0 or self._h > max_height: self._h = min(max_height, self._w / 2) self._xo = 0.0 diff --git a/dibbler/lib/printer_helpers.py b/dibbler/lib/printer_helpers.py index f1ea95a..0192971 100644 --- a/dibbler/lib/printer_helpers.py +++ b/dibbler/lib/printer_helpers.py @@ -2,9 +2,10 @@ import os import datetime import barcode -from brother_ql import BrotherQLRaster, create_label +from brother_ql.brother_ql_create import create_label +from brother_ql.raster import BrotherQLRaster from brother_ql.backends import backend_factory -from brother_ql.devicedependent import label_type_specs +from brother_ql.labels import ALL_LABELS from PIL import Image, ImageDraw, ImageFont from .barcode_helpers import BrotherLabelWriter @@ -17,10 +18,11 @@ def print_name_label( label_type="62", printer_type="QL-700", ): + label = next([l for l in ALL_LABELS if l.identifier == label_type]) if not rotate: - width, height = label_type_specs[label_type]["dots_printable"] + width, height = label.dots_printable else: - height, width = label_type_specs[label_type]["dots_printable"] + height, width = label.dots_printable font_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ChopinScript.ttf") fs = 2000 diff --git a/nix/dibbler.nix b/nix/dibbler.nix index 5780eb1..24dc21d 100644 --- a/nix/dibbler.nix +++ b/nix/dibbler.nix @@ -9,6 +9,10 @@ python3Packages.buildPythonApplication { format = "pyproject"; + # brother-ql is breaky breaky + # https://github.com/NixOS/nixpkgs/issues/285234 + dontCheckRuntimeDeps = true; + nativeBuildInputs = with python3Packages; [ setuptools ]; propagatedBuildInputs = with python3Packages; [ brother-ql diff --git a/pyproject.toml b/pyproject.toml index 9b9dbb6..3179a6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ classifiers = [ ] dependencies = [ "SQLAlchemy >= 2.0, <2.1", - # "brother-ql", + "brother-ql", "matplotlib", "psycopg2 >= 2.8, <2.10", "python-barcode", @@ -31,4 +31,3 @@ line-length = 100 [tool.ruff] line-length = 100 -