-
Notifications
You must be signed in to change notification settings - Fork 3
/
labelprinterTest.py
63 lines (48 loc) · 1.82 KB
/
labelprinterTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
# coding: utf-8
from __future__ import unicode_literals
import socket
from brotherprint import BrotherPrint
from labelprinter import Labelprinter
import labelprinterServeConf as conf
def getLined(txt):
pass
def testLabel(printjob):
TEST_FONT = 'lettergothic'
TEST_CHAR_SIZE = '75'
TEST_BOLD = 'on'
TEST_TEXT = "auf deinem Grab"
labelprinter = Labelprinter(conf=None, printjob=printjob)
labelprinter.printText(TEST_TEXT, charSize=TEST_CHAR_SIZE, font=TEST_FONT, bold=TEST_BOLD)
def testRaster(printjob):
printjob.invalidate()
printjob.initialize()
printjob.raster_mode()
printjob.print_line()
#printjob.print_line()
#printjob.print_line()
def testBarcode(printjob):
barcodes = ['code39', 'itf', 'ean8/upca', 'upce', 'codabar', 'code128', 'gs1-128', 'rss']
labelprinter = Labelprinter(conf=None, printjob=printjob)
labelprinter.printBarcode("TEST", barcodes[2])
# nope: 'code39', itf, ean8/upca, upce, codabar, gs1-128
#'itf',
#printjob.qr_code("test123", cell_size=10)
#printjob.barcode(str(123), 'rss', rss_symbol='rsslimited')
def testQRcode(printjob):
labelprinter = Labelprinter(conf=None, printjob=printjob)
# data, cell_size=4, symbol_type=2, partitioned=0, partition=0, parity=0, error_correction=4, data_input=0):
#printjob.qr_code(**{'data':'noot noot', 'cell_size':10, 'symbol_type':2})
printjob.qr_code('noot noot', 10)
printjob.line_feed()
printjob.select_font('lettergothic')
printjob.char_size('11')
printjob.send("noot noot")
printjob.char_style('normal')
printjob.print_page('full')
f_socket = socket.create_connection((conf.PRINTER_HOST, conf.PRINTER_PORT))
printjob = BrotherPrint(f_socket)
#testRaster(printjob)
#testLabel(printjob)
testQRcode(printjob)
#testBarcode(printjob) # FIXME