Comments (7)
Darn... I wonder if there's an easy fix for that. Any ideas, @koenbollen ?
from python-qrcode.
I think that changing "\x1b[1;47m"
to "\x1b[1;7m"
should help.
It would be black on white background and white on black background.
Or:
"\x1b[0m"
to "\x1b[1;40m"
- That one should work better.
Just remember to put out.write("\x1b[0m\n")
before out.flush()
from python-qrcode.
someone want to test that out on both a white and black background tty?
from python-qrcode.
def print_tty(self, out=None):
"""
Output the QR Code to a TTY (potentially useful for debugging).
If the data has not been compiled yet, make it first.
"""
if out is None:
import sys
out = sys.stdout
if not out.isatty():
raise OSError("Not a tty")
if self.data_cache is None:
self.make()
modcount = self.modules_count
out.write("\x1b[1;47m" + (" " * (modcount * 2 + 4)) + "\x1b[40m\n")
for r in range(modcount):
out.write("\x1b[1;47m \x1b[40m")
for c in range(modcount):
if self.modules[r][c]:
out.write(" ")
else:
out.write("\x1b[1;47m \x1b[40m")
out.write("\x1b[1;47m \x1b[40m\n")
out.write("\x1b[1;47m" + (" " * (modcount * 2 + 4)) + "\x1b[0m\n")
out.flush()
from python-qrcode.
Thanks @utek
In the future, a pull request is the way to go [using a branch]. They're pretty easy and means I can just click one button to merge ;)
E.g:
git remote add -f upstream git://github.com/lincolnloop/python-qrcode.git
(-f
saves us agit fetch upstream
)git checkout upstream/master -b tty-fix
- Make changes then
git commit -am "Make print_tty work on both black and white backgrounds. Fixes #4"
git push origin tty-fix
- Go to github, switch to the tty-fix branch, click the pull request button.
from python-qrcode.
Ok :) Next time I'll use pull requests. Thanks again for git hints :)
from python-qrcode.
Hey guys, when I woke up this morning it was already fixed. Nice.
For the record, I would've come up with the same fix.
Cheers,
Koen
from python-qrcode.
Related Issues (20)
- only black colored qr code with image_factory = qrcode.image.svg.SvgPathImage HOT 3
- Question about the ability of Qrcode
- Feature Request: Add 5x5 and 5x4/4x5 grids for transfer to paper
- Radius for the RoundedModuleDrawer
- Python 3.12: 'WindowsPath' object has no attribute 'write' HOT 2
- Circled eyes HOT 1
- Can you make the background of qrcode transparent? HOT 2
- Possibility to add a logo in the middle HOT 4
- 3.12 qr cli: ModuleNotFoundError: No module named 'pkg_resources' HOT 1
- SVG without height and width
- Improper SVG result
- Improve generation speed
- ScriptTest::test_factory test failure (7.4.2) with "No such file"
- AttributeError: 'SvgPathImage' object has no attribute 'mode'
- White lines appearing when generating codes
- Amount doesn't filled up automatically upi payment app
- qrcode fails tests with Pillow 10.3.0 HOT 1
- Qr code
- Should raise exception if using embedded image with incorrect error correction?
- show and tell: Added a qrcode example to the Markdown Exec galery
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 python-qrcode.