print Qrcode directly Zebra printer by python

Asked

Viewed 865 times

2

I am generating qrcodes by python, only that I want to print directly on zebra label printer, I can already print words contained in an entry, but when I try to print the error qrcode: code:

def printQrCode(self):
            img = os.path.join(self.defaultLocation, self.qrPhotoTxt.get() + ".jpg")
            image1 = Image.open(img)
            basewidth = 240
            wpercent = (basewidth / float(image1.size[0]))
            hsize = int((float(image1.size[1]) * float(wpercent)))
            image = image1.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
            self.photo = ImageTk.PhotoImage(image=image)
            self.imgPanel.create_image(2, 2, anchor=NW, image=self.photo)
            self.imgPanel.image = self.photo
            label = """
            ^XA

            ^FO10,15
            ^A0,40,20
            ^FD
            """+image+"""
            ^FS

            ^FO10,60
            ^A0,40,20
            ^FD
            Test Zebra
            ^FS

            ^FO10,105
            ^A0,40,20
            ^FD
            Test Zebra
            ^FS


            ^XZ
            """

            from zebra import zebra
            z = zebra('ZDesigner ZT230-200dpi ZPL')
            z.output(label)

error in question:

 Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Python27\lib\lib-tk\Tkinter.py", line 1532, in __call__
        return self.func(*args)
      File "E:/CharIp ServerFTP_1.1/CharIP_1.1.6/QRcodeTKinter.py", line 103, in printQrCode
        """+image+"""
    TypeError: cannot concatenate 'str' and 'instance' objects

Someone could help me?

1 answer

0


My son, you are trying to concatenate an image to a string, which makes no sense. Change the label to:

    label = """
            ^XA

            ^FO10,15
            ^A0,40,20
            ^FD

            ^FS

            ^FO10,60
            ^A0,40,20
            ^FD
            Test Zebra
            ^FS

            ^FO10,105
            ^A0,40,20
            ^FD
            Test Zebra
            ^FS


            ^XZ
            """

This will eliminate the Typeerror in question (You do not concatenate a string to an object that does not contain the special _str method). Look for the manuals on Zebra’s website to find out how to send the image to Zebra. Anyway, don’t use concatenation.

https://www.zebra.com/us/en.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.