print QRcode directly printer Zebra by python

0

I am generating qrcodes by python, so I want to print directly to the label printer zebra, I can already print words contained in an entry, but when I try to print the qrcode of the error: 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

Could someone help me?

    
asked by anonymous 27.09.2016 / 18:29

1 answer

0

My child, you are trying to concatenate an image to a string, which does not make 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 (A string is not concatenated to an object that does not include the special method __ str __). Look for the manuals on the Zebra website to find out how to send the image to Zebra. Anyway, do not use concatenation.

link

    
01.10.2016 / 09:44