1. Querying supported Labels and Printers#

This page covers accessing data about supported labels and printers.

1.1. Base Class#

The API is designed around ElementsManager - a class that wraps a static list of objects which each contain data about one element.

class brother_ql.helpers.ElementsManager#

A class managing a collection of ‘elements’. Those elements are expected to be objects that * can be compared for equality against each other * have the attribute .identifier

element_name = 'element'#

what an element is

elements = []#

list of elements contained by this manager

get(identifier: str, default=None)#

Returns the element object with the given identifier, or if it doesn’t exist, the default value

Parameters:
  • identifier – the identifier to look for

  • default – what to return if the given identifier is not found

identifiers()#

Returns a list of the identifiers of all the elements in this manager

iter_elements()#

Returns an iterator over all the element objects in this manager

iter_identifiers()#

Returns an iterator over the identifiers of all the elements in this manager

1.2. Printer Models#

class brother_ql.models.Model(identifier: str, min_max_length_dots: Tuple[int, int], min_max_feed: Tuple[int, int] = (35, 1500), number_bytes_per_row: int = 90, additional_offset_r: int = 0, mode_setting: bool = True, cutting: bool = True, expanded_mode: bool = True, compression: bool = True, two_color: bool = False, num_invalidate_bytes: int = 200)#

This class represents a printer model. All specifics of a certain model and the opcodes it supports should be contained in this class.

additional_offset_r: int#

The required additional offset from the right side

compression: bool#

Model has support for compressing the transmitted raster data. Some models with only USB connectivity don’t support compression.

cutting: bool#

Model has a cutting blade to automatically cut labels

expanded_mode: bool#

Model has support for the ‘expanded mode’ opcode. (So far, all models that have cutting support do).

identifier: str#

A string identifier given to each model implemented. Eg. ‘QL-500’.

min_max_feed: Tuple[int, int]#

The minimum and maximum amount of feeding a label

min_max_length_dots: Tuple[int, int]#

Minimum and maximum number of rows or ‘dots’ that can be printed. Together with the dpi this gives the minimum and maximum length for continuous tape printing.

mode_setting: bool#

Support for the ‘mode setting’ opcode

property name: str#

Returns the printer identifier (already human-readable)

num_invalidate_bytes: int#

Number of NULL bytes needed for the invalidate command.

two_color: bool#

Support for two color printing (black/red/white) available only on some newer models.

class brother_ql.models.ModelsManager#

Class for accessing the list of supported printer models

element_name = 'model'#

what an element is

1.3. Label Types#

class brother_ql.labels.Color(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Enumeration representing the colors to be printed on a label. Most labels only support printing black on white. Some newer ones can also print in black and red on white.

BLACK_RED_WHITE = 1#

The label can be printed in black, white & red.

BLACK_WHITE = 0#

The label can be printed in black & white.

class brother_ql.labels.FormFactor(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Enumeration representing the form factor of a label. The labels for the Brother QL series are supplied either as die-cut (pre-sized), or for more flexibility the continuous label tapes offer the ability to vary the label length.

DIE_CUT = 1#

rectangular die-cut labels

ENDLESS = 2#

endless (continuous) labels

ROUND_DIE_CUT = 3#

round die-cut labels

class brother_ql.labels.Label(identifier: str, tape_size: Tuple[int, int], form_factor: FormFactor, dots_total: Tuple[int, int], dots_printable: Tuple[int, int], offset_r: int, feed_margin: int = 0, restricted_to_models: List[str] = NOTHING, color: Color = Color.BLACK_WHITE)#

This class represents a label. All specifics of a certain label and what the rasterizer needs to take care of depending on the label choosen, should be contained in this class.

color: Color#

Some labels allow printing in red, most don’t.

dots_printable: Tuple[int, int]#

The printable area (width, length) of the label in dots (@300dpi).

dots_total: Tuple[int, int]#

The total area (width, length) of the label in dots (@300dpi).

feed_margin: int#

An additional amount of feeding when printing the label. This is non-zero for some smaller label sizes and for endless labels.

form_factor: FormFactor#

The type of label

identifier: str#

A string identifier given to each label that can be selected. Eg. ‘29’.

property name: str#

Return a formatted, human-readable name for the label

offset_r: int#

The required offset from the right side of the label in dots to obtain a centered printout.

restricted_to_models: List[str]#

If a label can only be printed with certain label printers, this member variable lists the allowed ones. Otherwise it’s an empty list.

tape_size: Tuple[int, int]#

The tape size of a single label (width, lenght) in mm. For endless labels, the length is 0 by definition.

works_with_model(model: str) bool#

Method to determine if certain label can be printed by the specified printer model.

class brother_ql.labels.LabelsManager#

Class for accessing the list of supported labels

element_name = 'label'#

what an element is

find_label_by_size(width: int, height: int)#

Finds a label that matches the given dimensions

Note: this will find the first matching label. This means it cannot autodetect 62red for the QL-8xx printers.