Comments (4)
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.
Thanks for the bug report. This issue should be fixed in 743d963. Please upgrade and test again.
from brother_ql.
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.
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)
- pre-cut when printing label
- Installation on Ubuntu 18.04 failed
- ItΒ΄s possible to print ZPL II codes? HOT 1
- [QL-700] Is it Possible to pass a TXT file path and print ? Could you please provide some example code on how to do this with python ?
- Multiple print jobs to brother QL-800
- Documentation improvements for linux
- Improve error message if label omitted
- usb.core.NoBackendError: No backend available
- Currently the printer can be specified either via an appropriate string or via an os.open() handle. HOT 2
- Raster image size error HOT 2
- Using 54x29 labels DK-3235 not present in label list HOT 3
- OSError: [Errno 22] Invalid argument When Sending Instructions HOT 1
- Installation fails on Linux (OpenSuse Leap 15.4 - current release) HOT 1
- Support for automated testing
- Project status HOT 6
- not working on a pi? HOT 8
- "brother_ql -b pyusb discover" doesn't find the printer HOT 3
- incompatible 'bytes' types in pyusb.py and reader.py (python 2.x exception after printing)
- Print Barcode HOT 2
- AttributeError exception due to backward incompatible change in Pillow 10.0.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brother_ql.