程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

(8) Pyqt designs and implements [factory code scanning and packing system] - Python realizes Zebra bar code printer to automatically print labels

編輯:Python

Catalog

One . Introduction to zebra

Two . Explanation of printing principle

You need to master the following knowledge points

1. Print over the network

Network printing - Source code

2. Print through serial port

Serial printing -  Source code

Serial printing - The label template

3、 ... and . More information  


One . Introduction to zebra

Zebra product | The printer 、 Barcode scanner, etc  

Zebra API Documentation | Developer Portal

Zebra printers   Commonly used in   Product identification 、 Asset management 、 Document tracking 、 Material management 、 Management of incoming and outgoing goods   And   Inventory, etc Barcode label printing .

Two . Explanation of printing principle

You need to master the following knowledge points

  • master ZPL(II) Grammatical knowledge
  • Can make ZPL The label template , Text , graphics , Bar code , Qr code etc. .
  • Basic printer parameters will be set .
  • Read printer configuration and status information .

1. Print over the network

  • The printer has a network card installed , Have IP Address .

Network printing - Source code

import imp
import socket
import time
from log import *
from config import *
g_config_printer = read_config("config/printer.json")
def sendto_printer(amount, id_number):
mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
label = (b"""
^XA
^FO15,40^BY3
^BAN,300,Y,N,N
^FO75,30
^FD%s^SFddddddddddddD,1,F^FS
^FO111,341
^GB50,50,50,W,0^FS
^FO444,341
^GB50,50,50,W,0^FS
^PQ%s
^XZ
""" % (bytes(id_number, encoding='utf-8'), bytes(amount, encoding='utf-8')))
logger.info(label)
try:
# connecting to host
mysocket.connect((g_config_printer["ip"], g_config_printer["port"]))
mysocket.send(label) # using bytes
mysocket.close() # closing connection
except Exception as e:
logger.error( e)
if __name__ == "__main__":
sendto_printer(amount, str(time.time()))

2. Print through serial port

Serial printing -  Source code

import serial
# Designated serial port
serialPort="COM3"
# Specify the baud rate
baudRate=9600
# Open the serial port
ser=serial.Serial(serialPort, baudRate, timeout=3)
CMD = open('.//SerialPrinter.txt')
data = CMD.readline()
# Sending and receiving data
while data:
ser.write(data)
print(data)
data = CMD.readline()
ser.close()

Serial printing - The label template

^XA
^SEE:GB18030.DAT^FS
^CWZ,E:KAITI.FNT
^JMA^LL200^PW680^MD10^RP2^PON^LRN^LH0,0
^FO20,100
^AZN,72,72
^FD Test label Qq123^FS
^XZ

3、 ... and . More information  

【 Factory scanning and printing & Scanning code and packing & Error tracking system 】 Complete case details (Python&PyQt Source code &Mysql database )_YYDataV Data visualization blog -CSDN Blog _pyqt Case study  

The end of this sharing , Welcome to exchange . WeChat 6550523 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved