Merge pull request #1 from freeyoung/master

Several small improvements
This commit is contained in:
Davis Goglin 2014-03-14 08:23:45 -07:00
commit 9fdb382c99
5 changed files with 24 additions and 25 deletions

View File

@ -10,7 +10,7 @@ In order to start getting access to your printer, you must ensure
you have previously installed the following python modules: you have previously installed the following python modules:
* pyusb (python-usb) * pyusb (python-usb)
* PIL (Python Image Library) * PIL (Python Image Library) or Pillow (recommended)
2. Description 2. Description
------------------------------------------------------------------ ------------------------------------------------------------------
@ -69,16 +69,15 @@ The following example shows how to initialize the Epson TM-TI88IV
*** NOTE: Always finish the sequence with Epson.cut() otherwise *** NOTE: Always finish the sequence with Epson.cut() otherwise
you will endup with weird chars being printed. you will endup with weird chars being printed.
from escpos import * from escpos import printer
""" Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """ p = printer.Usb(0x04b8, 0x0202)
Epson = escpos.Escpos(0x04b8,0x0202,0) p.text("Hello World")
Epson.text("Hello World") p.image("doge.jpg")
Epson.image("logo.gif") p.fullimage("a.really.large.image.png")
Epson.fullimage("a.really.large.image.png") p.barcode('1324354657687','EAN13',64,2,'','')
Epson.barcode p.qr('this is a piece of code')
Epson.barcode('1324354657687','EAN13',64,2,'','') p.cut()
Epson.cut()
5. Links 5. Links
------------------------------------------------------------------ ------------------------------------------------------------------

BIN
doge.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -6,11 +6,11 @@
@license: GPL @license: GPL
''' '''
import Image
import qrcode
import time
import os import os
import time
import qrcode
import operator import operator
from PIL import Image
from constants import * from constants import *
from exceptions import * from exceptions import *
@ -141,15 +141,15 @@ class Escpos:
self._print_image(pix_line, img_size) self._print_image(pix_line, img_size)
def qr(self,text): def qr(self, text):
""" Print QR Code for the provided string """ """ Print QR Code for the provided string """
qr_code = qrcode.QRCode(version=4, box_size=4, border=1) qr_code = qrcode.QRCode(version=4, box_size=4, border=1)
qr_code.add_data(text) qr_code.add_data(text)
qr_code.make(fit=True) qr_code.make(fit=True)
qr_img = qr_code.make_image() qr_img = qr_code.make_image()
im = qr_img._img.convert("RGB")
# Convert the RGB image in printable image # Convert the RGB image in printable image
self._convert_image(im) im = qr_img._img.convert("RGB")
self.image(im)
def barcode(self, code, bc, width, height, pos, font): def barcode(self, code, bc, width, height, pos, font):
""" Print Barcode """ """ Print Barcode """
@ -206,7 +206,7 @@ class Escpos:
def text(self, txt): def text(self, txt):
""" Print alpha-numeric text """ """ Print alpha-numeric text """
if txt: if txt:
self._raw(txt) self._raw(txt.encode('cp936'))
else: else:
raise TextError() raise TextError()

View File

@ -9,7 +9,7 @@ setup(
download_url='http://python-escpos.googlecode.com/files/python-escpos-1.0.zip', download_url='http://python-escpos.googlecode.com/files/python-escpos-1.0.zip',
description='Python library to manipulate ESC/POS Printers', description='Python library to manipulate ESC/POS Printers',
license='GNU GPL v3', license='GNU GPL v3',
long_description=open('README').read(), long_description=open('README.md').read(),
author='Manuel F Martinez', author='Manuel F Martinez',
author_email='manpaz@bashlinux.com', author_email='manpaz@bashlinux.com',
platforms=['linux'], platforms=['linux'],