Coder Social home page Coder Social logo

Comments (4)

nmaas87 avatar nmaas87 commented on May 18, 2024 1

Absolutely awesome! It works like a treat! πŸ‘ Thanks a lot for the very quick help!
Do you have any intention to make that program into a kind of Python API, so that you could call it as a function with an file and the needed variables to include that in own software? (It ain't needed, as one can really fastly call it via shell commands and such, but just as a question :)!)

from brother_ql.

pklaus avatar pklaus commented on May 18, 2024

Thanks for the bug report. This issue should be fixed in 743d963. Please upgrade and test again.

from brother_ql.

pklaus avatar pklaus commented on May 18, 2024

By the way: The errors in brother_ql_print show that you are using it with Python 2. It was not made for this.
I spent some work to make brother_ql_create work with Python 2, however (which is why it worked at all). You can simply print by using cat cafe.bin > /dev/usb/lp0 instead of brother_ql_print.

from brother_ql.

pklaus avatar pklaus commented on May 18, 2024

Do you have any intention to make that program into a kind of Python API, so that you could call it as a function with an file and the needed variables to include that in own software?

You can do:

from brother_ql import BrotherQLRaster, create_label
qlr = BrotherQLRaster("QL-570")
# image can be a PIL/Pillow Image() object or a file name to the GIF/PNG/JPEG image:
create_label(qlr, image, "62", threshold=70, cut=True)
# The binary image output is then available in this variable:
qlr.data

You can send this to your printer via simple Python:

import os
dev = os.open('/dev/usb/lp0', os.O_RDWR)
try:
    data = os.write(dev, qlr.data)
except KeyboardInterrupt:
    pass
finally:
    os.close(dev)

Or on Python 3 you can use brother_ql's more high-level variants:

from brother_ql.backends.linux_kernel import BrotherQLBackendLinuxKernel as BrotherQLBackend
printer = BrotherQLBackend("/dev/usb/lp0")
printer.write(qlr.data)

Unfortunately the API is not yet documented. It was also changing a lot until now. The above should, however, be quite stable.

from brother_ql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.