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:
* pyusb (python-usb)
* PIL (Python Image Library)
* PIL (Python Image Library) or Pillow (recommended)
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
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) """
Epson = escpos.Escpos(0x04b8,0x0202,0)
Epson.text("Hello World")
Epson.image("logo.gif")
Epson.fullimage("a.really.large.image.png")
Epson.barcode
Epson.barcode('1324354657687','EAN13',64,2,'','')
Epson.cut()
p = printer.Usb(0x04b8, 0x0202)
p.text("Hello World")
p.image("doge.jpg")
p.fullimage("a.really.large.image.png")
p.barcode('1324354657687','EAN13',64,2,'','')
p.qr('this is a piece of code')
p.cut()
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
'''
import Image
import qrcode
import time
import os
import time
import qrcode
import operator
from PIL import Image
from constants import *
from exceptions import *
@ -141,15 +141,15 @@ class Escpos:
self._print_image(pix_line, img_size)
def qr(self,text):
def qr(self, text):
""" Print QR Code for the provided string """
qr_code = qrcode.QRCode(version=4, box_size=4, border=1)
qr_code.add_data(text)
qr_code.make(fit=True)
qr_img = qr_code.make_image()
im = qr_img._img.convert("RGB")
# 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):
""" Print Barcode """
@ -206,7 +206,7 @@ class Escpos:
def text(self, txt):
""" Print alpha-numeric text """
if txt:
self._raw(txt)
self._raw(txt.encode('cp936'))
else:
raise TextError()

View File

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