You can do this with two options COM Ports and USB Ports
with the com you need to send via serial with pyserial creating the serial interface enabling the com port(windows) or tty(linux) and with the method .write("string zpl") you must print something
the another way is to install the printer via native drivers (linux is very easy) and you print the zpl file via terminal like this
#lpr -P ALIASPRINTER -o raw filezpl.zpl
and the printer will prints via LPR Command on terminal
Here is the main doc and support for pySerial library
https://pypi.org/project/pyserial/
Here is a guide for LPR
https://man7.org/linux/man-pages/man1/lpr.1.html
code below
class W_THREAD(QThread, object):
w_signal = pyqtSignal(object)
def __init__(self, event,portstr):
QThread.__init__(self)
self.port = portstr
self.baudrate = 2400
self.parity = serial.PARITY_NONE
self.stopbits = serial.STOPBITS_ONE
self.bytesize = serial.EIGHTBITS
self.timeout = 2
self.serial = serial.Serial(
port=self.port,
baudrate = self.baudrate,
parity=self.parity,
stopbits=self.stopbits,
bytesize=self.bytesize,
timeout=self.timeout
)
self.stopped = event
def kill_thread(self):
self.w_signal.emit(0)
def run(self):
try:
print("here >>> "+str(self.stopped))
while not self.stopped.wait(0.001):
self.get_w()
except:
self.w_signal.emit(0)
def get_w(self):
w_active = self.serial.readline()
self.w_signal.emit(w_active)
def writteserial(self,cmd): #here write the zpl output!!
self.serial.write(cmd)
def LISTENER_W(self):
try:
self.stop_flag_time = Event()
self.w_1 = W_THREAD(self.stop_flag_time,self.WEIGHT_PORT)
self.w_1.start()
self.w_1.w_signal.connect(self.update_w44)
print(str(self.stop_flag_time))
except:
print("exception")
def update_w44(self,w):
try:
number = self.only_num2(str(w))
the_fuck_number_w = str(number)
except:
print("exception")
Cheers up