πŸ“˜ APIΒΆ

ClassΒΆ

class thermalprinter.ThermalPrinter(port: str = '/dev/ttyAMA0', *, baudrate: int = 19200, byte_time: float = 5e-05, command_timeout: float = 0.05, dot_feed_time: float = 0.0021, dot_print_time: float = 0.03, heat_interval: int = 2, heat_time: int = 80, most_heated_point: int = 9, read_timeout: float = 0.0, run_setup_cmd: bool = True, use_stats: bool = True, write_timeout: float = 1.0)ΒΆ

The class managing the thermal printer.

Parameters:
Raises:

ThermalPrinterValueError – On incorrect argument’s type, or value.

Added in version 0.3.0: The command_timeout keyword-argument.

Added in version 1.0.0: byte_time, dot_feed_time, dot_print_time, run_setup_cmd, read_timeout, use_stats, and write_timeout, keyword-arguments.

MethodsΒΆ

PrintingΒΆ

ThermalPrinter.demo() None ΒΆ

Show time!

Demonstrate printer capabilities.

Added in version 1.0.0.

ThermalPrinter.feed(number: int = 1) None ΒΆ

Feed by the specified number of lines.

Parameters:

number (int ) – The number of lines (min=0, max=255).

Raises:

ThermalPrinterValueError – On incorrect number’s type, or value.

ThermalPrinter.out(data: Any, line_feed: bool = True, **kwargs: Any) None ΒΆ

Send one line to the printer.

Parameters:
  • data (mixed) – The data to print.

  • line_feed (bool ) – Wether or not to issue a final line feed (\n character).

  • kwargs (dict ) – Additional styles to apply.

You can pass formatting instructions directly via arguments:

>>> printer.out(data, justify=Justify.CENTER, inverse=True)

This is a quicker way to do:

>>> printer.justify(Justify.CENTER)
>>> printer.inverse(True)
>>> printer.out(data)
>>> printer.inverse(False)
>>> printer.justify(Justify.LEFT)

Hint

A special boolean keyword-argument can be used to print Persian text: persian=True. It will reshape data, and set proper text styles to issue the final text.

See recipes for required dependencies.

Added in version 1.0.0: The persian keyword-argument.


BarcodesΒΆ

ThermalPrinter.barcode(data: str , barcode_type: BarCode, **kwargs: Any) None ΒΆ

Barcode printing. All checks are done to ensure the data validity.

Parameters:
  • data (str ) – The data to print.

  • barecode_type (BarCode) – The barcode type to use.

  • kwargs (dict ) – Additional barcode properties to apply.

Raises:

ThermalPrinterValueError – On incorrect data’s type, or value.

You can set additional barcode properties via arguments:

>>> printer.barcode(
...     "012345678901",
...     BarCode.EAN13,
...     width=3,
...     height=80,
...     left_margin=2,
...     position=BarCodePosition.BELOW)

This is a quicker way to do:

>>> printer.barcode_width(3)
>>> printer.barcode_height(80)
>>> printer.barcode_left_margin(2)
>>> printer.barcode_position(BarCodePosition.BELOW)
>>> printer.barcode("012345678901", BarCode.EAN13)

Added in version 1.0.0: The kwargs keyword-argument to set additional barcode properties.

ThermalPrinter.barcode_height(height: int = 162) None ΒΆ

Set the barcode height.

Parameters:

height (int ) – The barcode height (min=1, max=255).

Raises:

ThermalPrinterValueError – On incorrect height’s type, or value.

ThermalPrinter.barcode_left_margin(margin: int = 0) None ΒΆ

Set the left margin of the barcode.

Parameters:

margin (int ) – The barcode left margin (min=0, max=255).

Raises:

ThermalPrinterValueError – On incorrect margin’s type, or value.

ThermalPrinter.barcode_position(position: BarCodePosition = BarCodePosition.HIDDEN) None ΒΆ

Set the position of the text relative to the barcode.

Parameters:

position (BarCodePosition) – The barcode position to use.

ThermalPrinter.barcode_width(width: int = 3) None ΒΆ

Set the barcode width.

Parameters:

width (int ) – The barcode with (min=2, max=6).

Raises:

ThermalPrinterValueError – On incorrect width’s type, or value.

static ThermalPrinter.validate_barcode(data: str , barcode_type: BarCode) None ΒΆ

Validate data against the barcode type.

Parameters:
  • data (str ) – The data to print.

  • barecode_type (BarCode) – The barcode type to validate.

Raises:

ThermalPrinterValueError – On incorrect data’s type, or value.

Added in version 1.0.0.


ImagesΒΆ

ThermalPrinter.image(image: Any) None ΒΆ

Picture printing.

Requires the Python Imaging Library (Pillow). The image will be resized to 384 pixels width (constants.MAX_IMAGE_WIDTH) if necessary, and converted to 1-bit without diffusion dithering.

Parameters:

image (str | pathlib.Path | PIL.Image) – The file, or PIL Image object, to print.

Examples:

>>> printer.image("picture.png")
>>> from pathlib import Path
>>> printer.image(Path.home() / "picture.png")
>>> from PIL import Image
>>> printer.image(Image.open("picture.png"))

Changed in version 1.0.0: image can also be a str , or pathlib.Path , in addition to the original PIL.Image object.

Tip

Since v1.0.0 the image will be automatically resized when too wide.

Important

It works better with white background instead of transparence.

ThermalPrinter.image_chunks(image: Any) bytearray ΒΆ

TODO Convert a given image to 1-bit without diffusion dithering, if necessary.

Parameters:

image (PIL.Image) – The PIL Image object to handle.

Return type:

bytearray

Returns:

The converted image object, if converted, else the original image.

Hint

Usually you do not need to call this method manually. It is used automatically by the image() method.

Added in version 1.0.0.

ThermalPrinter.image_convert(image: Any) AnyΒΆ

Convert a given image to 1-bit without diffusion dithering, if necessary.

Parameters:

image (PIL.Image) – The PIL Image object to convert.

Return type:

PIL.Image

Returns:

The converted image object, if converted, else the original image.

Hint

Usually you do not need to call this method manually. It is used automatically by the image() method.

Added in version 1.0.0.

ThermalPrinter.image_resize(image: Any) AnyΒΆ

Resize a given image to fit into the maximum width of 384 pixels (constants.MAX_IMAGE_WIDTH), if necessary. The size proportion will be respected.

Parameters:

image (PIL.Image) – The PIL Image object to resize.

Return type:

PIL.Image

Returns:

The resized image object, if resized, else the original image.

Hint

Usually you do not need to call this method manually. It is used automatically by the image() method.

Added in version 1.0.0.


Text StylingΒΆ

ThermalPrinter.bold(state: bool = False) None ΒΆ

Turn on/off the emphasized mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

ThermalPrinter.char_spacing(spacing: int = 0) None ΒΆ

Set the character spacing.

Parameters:

spacing (int ) – The spacing to use (min=0, max=255).

Raises:

ThermalPrinterValueError – On incorrect spacing’s type, or value.

ThermalPrinter.double_height(state: bool = False) None ΒΆ

Turn on/off the double height mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

ThermalPrinter.double_width(state: bool = False) None ΒΆ

Turn on/off the double width mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

ThermalPrinter.font_b(state: bool = False) None ΒΆ

Turn on/off the font B mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

Added in version 1.0.0.

ThermalPrinter.inverse(state: bool = False) None ΒΆ

Turn on/off the white/black reverse printing mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

ThermalPrinter.justify(value: Justify = Justify.LEFT) None ΒΆ

Set the text justification.

Parameters:

value (Justify) – The justification to use.

Changed in version 1.0.0: The value keyword-argument was converted from a str to constants.Justify.

ThermalPrinter.left_blank(value: int = 0) None ΒΆ

Set the left margin, in points.

Parameters:

value (int ) – Value to pass to the printer (min=0, max=255).

Raises:

ThermalPrinterValueError – On incorrect value’s type, or value.

Added in version 1.0.0.

ThermalPrinter.left_margin(margin: int = 0) None ΒΆ

Set the left margin, in 8-points.

Parameters:

margin (int ) – The new margin (min=0, max=47).

Raises:

ThermalPrinterValueError – On incorrect margin’s type, or value.

ThermalPrinter.line_spacing(spacing: int = 30) None ΒΆ

Set the line spacing.

Parameters:

spacing (int ) – The new spacing (min=0, max=255).

Raises:

ThermalPrinterValueError – On incorrect spacing’s type, or value.

ThermalPrinter.rotate(state: bool = False) None ΒΆ

Turn on/off 90Β° clockwise rotation.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

ThermalPrinter.size(value: Size = Size.SMALL) None ΒΆ

Set the text size.

Parameters:

value (Size) – The size to use.

Note

This method affects max_column.

Changed in version 1.0.0: The value keyword-argument was converted from a str to constants.Size.

ThermalPrinter.strike(state: bool = False) None ΒΆ

Turn on/off the double-strike mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

ThermalPrinter.underline(weight: Underline = Underline.OFF) None ΒΆ

Set the underline mode.

Parameters:

weight (Underline) – The underline weight to use.

Changed in version 1.0.0: The weight keyword-argument was converted from an int to constants.Underline.

ThermalPrinter.upside_down(state: bool = False) None ΒΆ

Turns on/off the upside-down printing mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.


Encoding and CharsetsΒΆ

ThermalPrinter.charset(charset: CharSet = CharSet.USA) None ΒΆ

Set the character set.

Parameters:

charset (CharSet) – The new charset to use.

ThermalPrinter.codepage(codepage: CodePage = CodePage.CP437) None ΒΆ

Set the character code table.

Parameters:

codepage (CodePage) – The new code page to use.


ChineseΒΆ

ThermalPrinter.chinese(state: bool = False) None ΒΆ

Turn on/off Chinese mode.

Parameters:

state (bool ) – Enabled if state is True, else disabled.

ThermalPrinter.chinese_format(fmt: Chinese = Chinese.GBK) None ΒΆ

Set the Chinese format.

Parameters:

fmt (Chinese) – The new Chinese format to use.


Printer StateΒΆ

ThermalPrinter.offline() None ΒΆ

Take the printer offline. Upcoming print commands issued will be ignored until online() is called.

ThermalPrinter.online() None ΒΆ

Take the printer online. Subsequent print commands will be obeyed.

ThermalPrinter.sleep(seconds: int = 1) None ΒΆ

Put the printer into a low-energy state.

Parameters:

seconds (int ) – Value to pass to the printer (min=0).

Raises:

ThermalPrinterValueError – On incorrect seconds’s type, or value.

ThermalPrinter.status(*, raise_on_error: bool = True) dict [str , bool ]ΒΆ

Return the printer status.

Parameters:

raise_on_error (bool ) – Raise on error.

Raises:

ThermalPrinterCommunicationError – If the RX pin is not connected, and if raise_on_error is True.

Return type:

dict [str , bool ]

Returns:

See status_to_dict().

Added in version 0.2.0: The raise_on_error keyword-argument.

Removed in version 1.0.0: The movement key as it would always be False.

static ThermalPrinter.status_to_dict(stat: int ) dict [str , bool ]ΒΆ

Return the printer status as a dict.

Return type:

dict [str , bool ]

Returns:

Contains those keys:

  • paper: False if no paper

  • temp: False if the temperature exceeds 60Β°C

  • voltage: False if the voltage is higher than 9.5V

Added in version 1.0.0.

ThermalPrinter.reset() None ΒΆ

Reset the printer to factory defaults.

ThermalPrinter.test() None ΒΆ

Print the test page (including printer’s settings).

ThermalPrinter.wake() None ΒΆ

Wake up the printer.


Special MethodsΒΆ

ThermalPrinter.close() None ΒΆ

Persist statistics, if desired, and close the serial port.

ThermalPrinter.flush(clear: bool = False) None ΒΆ

Remove the print data from the output buffer.

Parameters:

clear (bool ) – Set to True to also clear the input buffer.

ThermalPrinter.init(heat_time: int ) None ΒΆ

Set printer heat properties.

Parameters:

heat_time (int ) – Printer heat time.

Added in version 1.0.0.

ThermalPrinter.print_char(char: str ) None ΒΆ

Test one character with all supported code pages.

Parameters:

char (str ) – The character to print.

Say you are looking for the good code page to print a sequence, you can print it using every code pages:

>>> printer.print_char("现")

Added in version 1.0.0.

ThermalPrinter.send_command(command: Command, *args: int ) None ΒΆ

Send a command to the printer.

Parameters:
  • command (Command) – The command to send to the printer.

  • args (list [int ]) – Eventual command arguments.

ThermalPrinter.to_bytes(data: Any) bytes ΒΆ

Convert data before sending to the printer.

Parameters:

data (mixed) – Any type of data to print.

Return type:

bytes

Returns:

The converted data in bytes.

AttributesΒΆ

All these attributes are read-only.

property ThermalPrinter.feeds: int ΒΆ

Number of printed line feeds.

property ThermalPrinter.has_paper: bool ΒΆ

Return True if there is paper.

property ThermalPrinter.is_online: bool ΒΆ

The printer online status.

property ThermalPrinter.is_sleeping: bool ΒΆ

The printer sleep status.

property ThermalPrinter.lines: int ΒΆ

Number of printed lines.

property ThermalPrinter.max_column: int ΒΆ

Number of printable characters on one line.

ConstantsΒΆ

Barcode TypesΒΆ

enum thermalprinter.constants.BarCode(value)ΒΆ

Barcode types.

Valid values are as follows:

UPC_A = <BarCode.UPC_A: 65, range: 11 <= len(data) <= 12>ΒΆ
UPC_E = <BarCode.UPC_E: 66, range: 11 <= len(data) <= 12>ΒΆ
JAN13 = <BarCode.JAN13: 67, range: 12 <= len(data) <= 13>ΒΆ
JAN8 = <BarCode.JAN8: 68, range: 7 <= len(data) <= 8>ΒΆ
CODE39 = <BarCode.CODE39: 69, range: 1 <= len(data) <= 255>ΒΆ
ITF = <BarCode.ITF: 70, range: 1 <= len(data) <= 255>ΒΆ
CODABAR = <BarCode.CODABAR: 71, range: 1 <= len(data) <= 255>ΒΆ
CODE93 = <BarCode.CODE93: 72, range: 1 <= len(data) <= 255>ΒΆ
CODE128 = <BarCode.CODE128: 73, range: 2 <= len(data) <= 255>ΒΆ

Barcode PositionsΒΆ

enum thermalprinter.constants.BarCodePosition(value)ΒΆ

Barcode positions.

Valid values are as follows:

HIDDEN = <BarCodePosition.HIDDEN: 0>ΒΆ
ABOVE = <BarCodePosition.ABOVE: 1>ΒΆ
BELOW = <BarCodePosition.BELOW: 2>ΒΆ
BOTH = <BarCodePosition.BOTH: 3>ΒΆ

Characters SetsΒΆ

enum thermalprinter.constants.CharSet(value)ΒΆ

Character sets.

Valid values are as follows:

USA = <CharSet.USA: 0>ΒΆ
FRANCE = <CharSet.FRANCE: 1>ΒΆ
GERMANY = <CharSet.GERMANY: 2>ΒΆ
UK = <CharSet.UK: 3>ΒΆ
DENMARK = <CharSet.DENMARK: 4>ΒΆ
SWEDEN = <CharSet.SWEDEN: 5>ΒΆ
ITALY = <CharSet.ITALY: 6>ΒΆ
SPAIN = <CharSet.SPAIN: 7>ΒΆ
JAPAN = <CharSet.JAPAN: 8>ΒΆ
NORWAY = <CharSet.NORWAY: 9>ΒΆ
DENMARK2 = <CharSet.DENMARK2: 10>ΒΆ
SPAIN2 = <CharSet.SPAIN2: 11>ΒΆ
LATIN_AMERICAN = <CharSet.LATIN_AMERICAN: 12>ΒΆ
KOREA = <CharSet.KOREA: 13>ΒΆ
SLOVENIA = <CharSet.SLOVENIA: 14>ΒΆ
CHINA = <CharSet.CHINA: 15>ΒΆ

Chinese FormatsΒΆ

enum thermalprinter.constants.Chinese(value)ΒΆ

Chinese formats.

Valid values are as follows:

GBK = <Chinese.GBK: 0>ΒΆ
UTF_8 = <Chinese.UTF_8: 1>ΒΆ
BIG5 = <Chinese.BIG5: 3>ΒΆ

Code PagesΒΆ

enum thermalprinter.constants.CodePage(value)ΒΆ

Character code tables.

Valid values are as follows:

CP437 = <CodePage.CP437: (0, 'the United States of America, European standard')>ΒΆ
CP932 = <CodePage.CP932: (1, 'Katakana')>ΒΆ
CP850 = <CodePage.CP850: (2, 'Multi language')>ΒΆ
CP860 = <CodePage.CP860: (3, 'Portuguese')>ΒΆ
CP863 = <CodePage.CP863: (4, 'Canada, French')>ΒΆ
CP865 = <CodePage.CP865: (5, 'Western Europe')>ΒΆ
CYRILLIC = <CodePage.CYRILLIC: (6, 'The Slavic language')>ΒΆ
CP866 = <CodePage.CP866: (7, 'The Slavic 2')>ΒΆ
MIK = <CodePage.MIK: (8, 'The Slavic / Bulgaria')>ΒΆ
CP755 = <CodePage.CP755: (9, 'Eastern Europe, Latvia 2')>ΒΆ
IRAN = <CodePage.IRAN: (10, 'Iran, Persia')>ΒΆ
CP862 = <CodePage.CP862: (15, 'Hebrew')>ΒΆ
CP1252 = <CodePage.CP1252: (16, 'Latin 1 [WCP1252]')>ΒΆ
CP1253 = <CodePage.CP1253: (17, 'Greece [WCP1253]')>ΒΆ
CP852 = <CodePage.CP852: (18, 'Latina 2')>ΒΆ
CP858 = <CodePage.CP858: (19, 'A variety of language Latin 1 + Europe')>ΒΆ
IRAN2 = <CodePage.IRAN2: (20, 'Persian')>ΒΆ
LATVIA = <CodePage.LATVIA: (21, '')>ΒΆ
CP864 = <CodePage.CP864: (22, 'Arabic')>ΒΆ
ISO_8859_1 = <CodePage.ISO_8859_1: (23, 'Western Europe')>ΒΆ
CP737 = <CodePage.CP737: (24, 'Greece')>ΒΆ
CP1257 = <CodePage.CP1257: (25, 'The Baltic Sea')>ΒΆ
THAI = <CodePage.THAI: (26, 'Thai Wen')>ΒΆ
CP720 = <CodePage.CP720: (27, 'Arabic')>ΒΆ
CP855 = <CodePage.CP855: (28, '')>ΒΆ
CP857 = <CodePage.CP857: (29, 'Turkish')>ΒΆ
CP1250 = <CodePage.CP1250: (30, 'Central Europe [WCP1250]')>ΒΆ
CP775 = <CodePage.CP775: (31, '')>ΒΆ
CP1254 = <CodePage.CP1254: (32, 'Turkish [WCP1254]')>ΒΆ
CP1255 = <CodePage.CP1255: (33, 'Hebrew [WCP1255]')>ΒΆ
CP1256 = <CodePage.CP1256: (34, 'Arabic [WCP1256]')>ΒΆ
CP1258 = <CodePage.CP1258: (35, 'Vietnamese [WCP1258]')>ΒΆ
ISO_8859_2 = <CodePage.ISO_8859_2: (36, 'Latin 2')>ΒΆ
ISO_8859_3 = <CodePage.ISO_8859_3: (37, 'Latin 3')>ΒΆ
ISO_8859_4 = <CodePage.ISO_8859_4: (38, 'Baltic languages')>ΒΆ
ISO_8859_5 = <CodePage.ISO_8859_5: (39, 'The Slavic language')>ΒΆ
ISO_8859_6 = <CodePage.ISO_8859_6: (40, 'Arabic')>ΒΆ
ISO_8859_7 = <CodePage.ISO_8859_7: (41, 'Greece')>ΒΆ
ISO_8859_8 = <CodePage.ISO_8859_8: (42, 'Hebrew')>ΒΆ
ISO_8859_9 = <CodePage.ISO_8859_9: (43, 'Turkish')>ΒΆ
ISO_8859_15 = <CodePage.ISO_8859_15: (44, 'Latin 9')>ΒΆ
THAI2 = <CodePage.THAI2: (45, 'Thai Wen 2')>ΒΆ
CP856 = <CodePage.CP856: (46, '')>ΒΆ
CP874 = <CodePage.CP874: (47, '')>ΒΆ

Code Pages FallbackΒΆ

enum thermalprinter.constants.CodePageConverted(value)ΒΆ

Some code pages are not available on Python, so we use a little translation table.

Valid values are as follows:

MIK = <CodePageConverted.MIK: 'ISO-8859-5'>ΒΆ
CP755 = <CodePageConverted.CP755: 'UTF-8'>ΒΆ
IRAN = <CodePageConverted.IRAN: 'CP1256'>ΒΆ
LATVIA = <CodePageConverted.LATVIA: 'ISO-8859-4'>ΒΆ
THAI = <CodePageConverted.THAI: 'ISO-8859-11'>ΒΆ

Note

If you find a better fit for one of the code page below, open an issue please (or better: send a patch ) πŸ€—

CommandsΒΆ

enum thermalprinter.constants.Command(value)ΒΆ

Codes used to send commands.

Valid values are as follows:

NONE = <Command.NONE: 0>ΒΆ
DC2 = <Command.DC2: 18>ΒΆ
ESC = <Command.ESC: 27>ΒΆ
FS = <Command.FS: 28>ΒΆ
GS = <Command.GS: 29>ΒΆ

Defaults ParametersΒΆ

enum thermalprinter.constants.Defaults(value)ΒΆ

Default printer parameters.

Hint

Most of them can be tweaked by special environment variables following the given syntax: TP_XXX. Example: export TP_BAUDRATE=9600 will set Defaults.BAUDRATE to 9600.

Valid values are as follows:

BARCODE_HEIGHT = <Defaults.BARCODE_HEIGHT: 162>ΒΆ
BARCODE_WIDTH = <Defaults.BARCODE_WIDTH: 3>ΒΆ
BAUDRATE = <Defaults.BAUDRATE: 19200>ΒΆ
BYTE_TIME = <Defaults.BYTE_TIME: 5e-05>ΒΆ
DOT_FEED_TIME = <Defaults.DOT_FEED_TIME: 0.0021>ΒΆ
DOT_PRINT_TIME = <Defaults.DOT_PRINT_TIME: 0.03>ΒΆ
HEAT_INTERVAL = <Defaults.HEAT_INTERVAL: 2>ΒΆ
HEAT_TIME = <Defaults.HEAT_TIME: 80>ΒΆ
LINE_SPACING = <Defaults.LINE_SPACING: 30>ΒΆ
MOST_HEATED_POINT = <Defaults.MOST_HEATED_POINT: 9>ΒΆ
PORT = <Defaults.PORT: '/dev/ttyAMA0'>ΒΆ
READ_TIMEOUT = <Defaults.READ_TIMEOUT: 0.0>ΒΆ
WRITE_TIMEOUT = <Defaults.WRITE_TIMEOUT: 1.0>ΒΆ

Text JustificationΒΆ

enum thermalprinter.constants.Justify(value)ΒΆ

Text justifications.

Valid values are as follows:

LEFT = <Justify.LEFT: 0>ΒΆ
CENTER = <Justify.CENTER: 1>ΒΆ
RIGHT = <Justify.RIGHT: 2>ΒΆ

Text SizeΒΆ

enum thermalprinter.constants.Size(value)ΒΆ

Text sizes.

  • MEDIUM will double the text height.

  • LARGE will both double the text height, and its width.

Valid values are as follows:

SMALL = <Size.SMALL: (0, 24, 32)>ΒΆ
MEDIUM = <Size.MEDIUM: (1, 48, 32)>ΒΆ
LARGE = <Size.LARGE: (17, 48, 16)>ΒΆ

Text UnderlineΒΆ

enum thermalprinter.constants.Underline(value)ΒΆ

Text underline weights.

Valid values are as follows:

OFF = <Underline.OFF: 0>ΒΆ
THIN = <Underline.THIN: 1>ΒΆ
THICK = <Underline.THICK: 2>ΒΆ

OtherΒΆ

thermalprinter.constants.MAX_IMAGE_WIDTH = 384ΒΆ

Max image width.

thermalprinter.constants.STATS_FILE = '~/.thermalprinter.json'ΒΆ

Printer statistics file. See tools for its usage.

ExceptionsΒΆ

exception thermalprinter.exceptions.ThermalPrinterErrorΒΆ

Base class for thermal printer exceptions.

exception thermalprinter.exceptions.ThermalPrinterCommunicationErrorΒΆ

Raised on communication error with the printer.

exception thermalprinter.exceptions.ThermalPrinterValueErrorΒΆ

Raised on incorrect type, or value, passed to any method.