🧰 Tools

Constants

thermalprinter.tools.ls(*consts: type [enum.Enum ]) None

Print constants values.

Parameters:

constants (list [type [enum.Enum ]]) – Constant(s) to print.

Print all constants:

>>> ls()

Print thermalprinter.constants.Chinese constant values:

>>> ls(Chinese)

Print thermalprinter.constants.Chinese, and thermalprinter.constants.CodePage, constant values:

>>> ls(Chinese, CodePage)

Statistics

Simple printer statistics can be persisted into the thermalprinter.constants.STATS_FILE file. They are enabled by default unless use_stats is set to False (see thermalprinter.ThermalPrinter()).

thermalprinter.tools.stats_file() Path

Return the full path to the statistics file.

thermalprinter.tools.stats_load() dict [str , int ]

Load statistics from the thermalprinter.constants.STATS_FILE file.

Return type:

dict [str , int ]

Returns:

Contains those keys:

  • feeds: total count of printed feeds

  • lines: total count of printed lines

thermalprinter.tools.stats_save(printer: ThermalPrinter) None

Save printer statistics to the thermalprinter.constants.STATS_FILE file.

Parameters:

printer (ThermalPrinter) – The Printer.