treewide: fix brother-ql usage
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
|||||||
|
|
||||||
from PIL import ImageFont
|
from PIL import ImageFont
|
||||||
from barcode.writer import ImageWriter, mm2px
|
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):
|
def px2mm(px, dpi=300):
|
||||||
@@ -12,14 +12,15 @@ def px2mm(px, dpi=300):
|
|||||||
class BrotherLabelWriter(ImageWriter):
|
class BrotherLabelWriter(ImageWriter):
|
||||||
def __init__(self, typ="62", max_height=350, rot=False, text=None):
|
def __init__(self, typ="62", max_height=350, rot=False, text=None):
|
||||||
super(BrotherLabelWriter, self).__init__()
|
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
|
self.rot = rot
|
||||||
if self.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:
|
if self._w == 0 or self._w > max_height:
|
||||||
self._w = min(max_height, self._h / 2)
|
self._w = min(max_height, self._h / 2)
|
||||||
else:
|
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:
|
if self._h == 0 or self._h > max_height:
|
||||||
self._h = min(max_height, self._w / 2)
|
self._h = min(max_height, self._w / 2)
|
||||||
self._xo = 0.0
|
self._xo = 0.0
|
||||||
|
@@ -2,9 +2,10 @@ import os
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import barcode
|
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.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 PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
from .barcode_helpers import BrotherLabelWriter
|
from .barcode_helpers import BrotherLabelWriter
|
||||||
@@ -17,10 +18,11 @@ def print_name_label(
|
|||||||
label_type="62",
|
label_type="62",
|
||||||
printer_type="QL-700",
|
printer_type="QL-700",
|
||||||
):
|
):
|
||||||
|
label = next([l for l in ALL_LABELS if l.identifier == label_type])
|
||||||
if not rotate:
|
if not rotate:
|
||||||
width, height = label_type_specs[label_type]["dots_printable"]
|
width, height = label.dots_printable
|
||||||
else:
|
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")
|
font_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ChopinScript.ttf")
|
||||||
fs = 2000
|
fs = 2000
|
||||||
|
@@ -9,6 +9,10 @@ python3Packages.buildPythonApplication {
|
|||||||
|
|
||||||
format = "pyproject";
|
format = "pyproject";
|
||||||
|
|
||||||
|
# brother-ql is breaky breaky
|
||||||
|
# https://github.com/NixOS/nixpkgs/issues/285234
|
||||||
|
dontCheckRuntimeDeps = true;
|
||||||
|
|
||||||
nativeBuildInputs = with python3Packages; [ setuptools ];
|
nativeBuildInputs = with python3Packages; [ setuptools ];
|
||||||
propagatedBuildInputs = with python3Packages; [
|
propagatedBuildInputs = with python3Packages; [
|
||||||
brother-ql
|
brother-ql
|
||||||
|
@@ -13,7 +13,7 @@ classifiers = [
|
|||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"SQLAlchemy >= 2.0, <2.1",
|
"SQLAlchemy >= 2.0, <2.1",
|
||||||
# "brother-ql",
|
"brother-ql",
|
||||||
"matplotlib",
|
"matplotlib",
|
||||||
"psycopg2 >= 2.8, <2.10",
|
"psycopg2 >= 2.8, <2.10",
|
||||||
"python-barcode",
|
"python-barcode",
|
||||||
@@ -31,4 +31,3 @@ line-length = 100
|
|||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 100
|
line-length = 100
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user