1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-09-13 09:09:58 +00:00

formatting

This commit is contained in:
Patrick Kanzler
2023-08-10 23:29:26 +02:00
parent b1011a1ee5
commit 1b4230fdd9
17 changed files with 128 additions and 104 deletions

View File

@@ -1,5 +1,4 @@
""" Example for printing barcodes.
"""
"""Example for printing barcodes."""
from escpos.printer import Usb
# Adapt to your needs

View File

@@ -1,5 +1,4 @@
"""Prints code page tables.
"""
"""Prints code page tables."""
import sys
@@ -19,6 +18,7 @@ from escpos.constants import (
def main():
"""Init printer and print codepage tables."""
dummy = printer.Dummy()
dummy.hw("init")
@@ -35,6 +35,7 @@ def main():
def print_codepage(printer, codepage):
"""Print a codepage."""
if codepage.isdigit():
codepage = int(codepage)
printer._raw(CODEPAGE_CHANGE + six.int2byte(codepage))

View File

@@ -1,3 +1,4 @@
"""Example for a flask application."""
from flask import Flask
from escpos.printer import CupsPrinter
@@ -8,6 +9,7 @@ app = Flask(__name__)
@app.route("/", methods=["GET"])
def do_print():
"""Print."""
# p = Usb(0x04b8, 0x0e28, 0)
p = CupsPrinter(host="localhost", port=631, printer_name="TM-T20III")
p.text("Hello World\n")

View File

@@ -1,9 +1,11 @@
"""Print example QR codes."""
import sys
from escpos.printer import Usb
def usage():
"""Print information on usage."""
print("usage: qr_code.py <content>")

View File

@@ -1,3 +1,4 @@
"""Example file for software barcodes."""
from escpos.printer import Usb
# Adapt to your needs

View File

@@ -1,16 +1,17 @@
#!/usr/bin/python
"""Weather forecast example.
Adapted script from Adafruit
Weather forecast for Raspberry Pi w/Adafruit Mini Thermal Printer.
Retrieves data from DarkSky.net's API, prints current conditions and
forecasts for next two days.
Weather example using nice bitmaps.
Written by Adafruit Industries. MIT license.
Adapted and enhanced for escpos library by MrWunderbar666
# Adapted script from Adafruit
# Weather forecast for Raspberry Pi w/Adafruit Mini Thermal Printer.
# Retrieves data from DarkSky.net's API, prints current conditions and
# forecasts for next two days.
# Weather example using nice bitmaps.
# Written by Adafruit Industries. MIT license.
# Adapted and enhanced for escpos library by MrWunderbar666
# Icons taken from https://adamwhitcroft.com/climacons/
# Check out his github: https://github.com/AdamWhitcroft/climacons
Icons taken from https://adamwhitcroft.com/climacons/
Check out his github: https://github.com/AdamWhitcroft/climacons
"""
import calendar
@@ -22,7 +23,7 @@ from datetime import datetime
from escpos.printer import Usb
""" Setting up the main pathing """
"""Set up the main pathing."""
this_dir, this_filename = os.path.split(__file__)
GRAPHICS_PATH = os.path.join(this_dir, "graphics/climacons/")
@@ -38,13 +39,14 @@ LONG = "114.189945" # Your Location
def forecast_icon(idx):
"""Get right icon for forecast."""
icon = data["daily"]["data"][idx]["icon"]
image = GRAPHICS_PATH + icon + ".png"
return image
# Dumps one forecast line to the printer
def forecast(idx):
"""Dump one forecast line to the printer."""
date = datetime.fromtimestamp(int(data["daily"]["data"][idx]["time"]))
day = calendar.day_name[date.weekday()]
lo = data["daily"]["data"][idx]["temperatureMin"]
@@ -73,6 +75,7 @@ def forecast(idx):
def icon():
"""Get icon."""
icon = data["currently"]["icon"]
image = GRAPHICS_PATH + icon + ".png"
return image