How to use the escpos.printer.Usb function in escpos

To help you get started, we’ve selected a few escpos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-escpos / python-escpos / examples / weather.py View on Github external
from __future__ import print_function
from datetime import datetime
import calendar
import urllib
import json
import time
import os

from escpos.printer import Usb

""" Setting up the main pathing """
this_dir, this_filename = os.path.split(__file__)
GRAPHICS_PATH = os.path.join(this_dir, "graphics/climacons/")

# Adapt to your needs
printer = Usb(0x0416, 0x5011, profile="POS-5890")

# You can get your API Key on www.darksky.net and register a dev account.
# Technically you can use any other weather service, of course :)
API_KEY = "YOUR API KEY"

LAT = "22.345490"       # Your Location
LONG = "114.189945"     # Your Location


def forecast_icon(idx):
    icon = data['daily']['data'][idx]['icon']
    image = GRAPHICS_PATH + icon + ".png"
    return image


# Dumps one forecast line to the printer
github StreakyCobra / raposfly / services / backend / shop / tickets.py View on Github external
def update_printer():
    """Update the printer."""
    global PRINTER  # pylint: disable=global-statement
    try:
        if len(config.PRINTER_ADDR.split()) == 2:
            vid, mid = config.PRINTER_ADDR.split()
            try:
                PRINTER = Usb(int(vid, 16), int(mid, 16))
            except ValueError:
                pass
    except USBNotFoundError:
        PRINTER = None
github python-escpos / python-escpos / examples / qr_code.py View on Github external
from escpos.printer import Usb


def usage():
    print("usage: qr_code.py <content>")


if __name__ == '__main__':
    if len(sys.argv) != 2:
        usage()
        sys.exit(1)

    content = sys.argv[1]

    # Adapt to your needs
    p = Usb(0x0416, 0x5011, profile="POS-5890")
    p.qr(content, center=True)
</content>
github OpenPymeMx / ProxyPoS / proxypos / proxypos / controlers / printer.py View on Github external
def open_cashbox():
    from proxypos.proxypos import config
    # Init printer
    ptype = config.get('printer.type').lower()
    settings = config.get('printer.settings')
    idVendor = settings['idVendor']
    idProduct = settings['idProduct']
    if ptype == 'usb':
        with printer.Usb(idVendor, idProduct) as device:
            device.cashdraw(2)
    elif ptype == 'serial':
        # TODO:
        printer.Serial(settings['devfile'])
    elif ptype == 'network':
        # TODO:
        printer.Network(settings['host'])
github OpenPymeMx / ProxyPoS / proxypos / proxypos / controlers / printer.py View on Github external
def is_alive():
    from proxypos.proxypos import config
    # Init printer
    ptype = config.get('printer.type').lower()
    settings = config.get('printer.settings')
    idVendor = settings['idVendor']
    idProduct = settings['idProduct']
    if ptype == 'usb':
        with printer.Usb(idVendor, idProduct) as device:
            pass
    elif ptype == 'serial':
        # TODO:
        printer.Serial(settings['devfile'])
    elif ptype == 'network':
        # TODO:
        printer.Network(settings['host'])
github OpenPymeMx / ProxyPoS / proxypos / proxypos / controlers / printer.py View on Github external
def print_receipt(receipt):
    """ Function used for print the receipt
    """
    # Import configuration handler
    from proxypos.proxypos import config
    from proxypos.proxypos import tmphandler

    # Init printer
    ptype = config.get('printer.type').lower()
    settings = config.get('printer.settings')
    idVendor = settings['idVendor']
    idProduct = settings['idProduct']
    if ptype == 'usb':
        with printer.Usb(idVendor, idProduct) as device:
            # Assign other default values
            device.pxWidth = settings['pxWidth']
            # Set default widht with normal value
            device.width = device.widthA = settings['WidthA']
            device.widthB = settings['WidthB']
            # Set correct table character
            if 'charSet' in settings:
                device.text(settings['charSet'])
            template = config.get('receipt.template')
            # Render and print receipt
            tmphandler.print_receipt(device, template, receipt)
    elif ptype == 'serial':
        # TODO:
        printer.Serial(settings['devfile'])
    elif ptype == 'network':
        # TODO:
github mrf345 / FQM / app / printer.py View on Github external
def assign(v, p, in_ep, out_ep):
    try:
        printer = getp.Usb(v, p, 0, in_ep, out_ep)
        printer.text("\n")
        return printer
    except Exception:
        return None
github python-escpos / python-escpos / examples / barcodes.py View on Github external
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from escpos.printer import Usb


# Adapt to your needs
p = Usb(0x0416, 0x5011, profile='POS-5890')

# Print software and then hardware barcode with the same content
p.soft_barcode('code39', '123456')
p.text('\n')
p.text('\n')
p.barcode('123456', 'CODE39')
github HH95 / HH---POS-Accounting-and-ERP-Software / hh / printer.py View on Github external
def connectToPrinter():
	try:
		p = Usb(0x0416, 0x5011, in_ep=81, out_ep=3)
	except USBNotFoundError:
		p = None
		print("Printer not connected")
	return p