| 1 |
from attr import attrs, attrib |
| 2 |
from typing import Tuple |
| 3 |
|
| 4 |
import copy |
| 5 |
|
| 6 |
from brother_ql.helpers import ElementsManager |
| 7 |
|
| 8 |
@attrs |
| 9 |
class Model(object): |
| 10 |
""" |
| 11 |
This class represents a printer model. All specifics of a certain model |
| 12 |
and the opcodes it supports should be contained in this class. |
| 13 |
""" |
| 14 |
#: A string identifier given to each model implemented. Eg. 'QL-500'. |
| 15 |
identifier = attrib(type=str) |
| 16 |
#: Minimum and maximum number of rows or 'dots' that can be printed. |
| 17 |
#: Together with the dpi this gives the minimum and maximum length |
| 18 |
#: for continuous tape printing. |
| 19 |
min_max_length_dots = attrib(type=Tuple[int, int]) |
| 20 |
#: The minimum and maximum amount of feeding a label |
| 21 |
min_max_feed = attrib(type=Tuple[int, int], default=(35, 1500)) |
| 22 |
number_bytes_per_row = attrib(type=int, default=90) |
| 23 |
#: The required additional offset from the right side |
| 24 |
additional_offset_r = attrib(type=int, default=0) |
| 25 |
#: Support for the 'mode setting' opcode |
| 26 |
mode_setting = attrib(type=bool, default=True) |
| 27 |
#: Model has a cutting blade to automatically cut labels |
| 28 |
cutting = attrib(type=bool, default=True) |
| 29 |
#: Model has support for the 'expanded mode' opcode. |
| 30 |
#: (So far, all models that have cutting support do). |
| 31 |
expanded_mode = attrib(type=bool, default=True) |
| 32 |
#: Model has support for compressing the transmitted raster data. |
| 33 |
#: Some models with only USB connectivity don't support compression. |
| 34 |
compression = attrib(type=bool, default=True) |
| 35 |
#: Support for two color printing (black/red/white) |
| 36 |
#: available only on some newer models. |
| 37 |
two_color = attrib(type=bool, default=False) |
| 38 |
|
| 39 |
@property |
| 40 |
def name(self): |
| 41 |
return self.identifier |
| 42 |
|
| 43 |
ALL_MODELS = [ |
| 44 |
Model('QL-500', (295, 11811), compression=False, mode_setting=False, expanded_mode=False, cutting=False), |
| 45 |
Model('QL-550', (295, 11811), compression=False, mode_setting=False), |
| 46 |
Model('QL-560', (295, 11811), compression=False, mode_setting=False), |
| 47 |
Model('QL-570', (150, 11811), compression=False, mode_setting=False), |
| 48 |
Model('QL-580N', (150, 11811)), |
| 49 |
Model('QL-650TD', (295, 11811)), |
| 50 |
Model('QL-700', (150, 11811), compression=False, mode_setting=False), |
| 51 |
Model('QL-710W', (150, 11811)), |
| 52 |
Model('QL-720NW', (150, 11811)), |
| 53 |
Model('QL-800', (150, 11811), two_color=True, compression=False), |
| 54 |
Model('QL-810W', (150, 11811), two_color=True), |
| 55 |
Model('QL-820NWB',(150, 11811), two_color=True), |
| 56 |
Model('QL-1050', (295, 35433), number_bytes_per_row=162, additional_offset_r=44), |
| 57 |
Model('QL-1060N', (295, 35433), number_bytes_per_row=162, additional_offset_r=44), |
| 58 |
] |
| 59 |
|
| 60 |
class ModelsManager(ElementsManager): |
| 61 |
DEFAULT_ELEMENTS = copy.copy(ALL_MODELS) |
| 62 |
ELEMENTS_NAME = 'model' |