python-barcode
python-barcode copied to clipboard
Feature request - terminal output
Sometimes you want to generate and scan a code in a terminal. Here is a thing I tried out, maybe it could become a feature in this library.
I made a quick example here but I am not sure I understand the proper way of subclassing BaseWriter in this project.
It will output something like the image below. Only tested on dark terminal with code128.
I could only fit 2 sub modules per character because I could only find box drawing characters that could span all combinations for half width. If there is a right 3/4 bar one could double the density but I have not looked for one.
This looks pretty convenient.
Currently subclasses of BaseWriter are in barcode/writer.py, I think it's feasible to include an AsciiWriter there. The target can be a file-like, where one can pass simply stdout or an actual file.
If you want to take a shot at it, happy to review a PR for it.
Cool. Maybe you could just have a quick look at the implementation and see if it looks ready to integrate or if I have misunderstood the process. I just now had a look at SVGWriter and it looks like I initialized my ascii writer the same way, using an upstream __init__ with callbacks as arguments from my local __init__.
You will notice that I am not doing anything in paint_module because I already computed the result in __init__.
Thank you