From 604b6b0fbd8bf924b869630409ac26ba1e64ad58 Mon Sep 17 00:00:00 2001 From: tempdban Date: Sun, 31 Jul 2016 00:36:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=89=B2=E5=9D=97=E5=8F=8D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 我的控制台背景是白的... --- README.md | 6 ++++++ README.rst | 6 ++++++ README_EN.md | 6 ++++++ itchat/tools.py | 7 ++++--- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d51304a..68fb062b 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,12 @@ itchat.auto_login(enableCmdQR = True) itchat.auto_login(enableCmdQR = 2) ``` +默认控制台背景色为暗色(黑色),若背景色为浅色(白色),可以将enableCmdQR赋值为负值: + +```python +itchat.auto_login(enableCmdQR = -1) +``` + ### 退出程序后暂存登陆状态 通过如下命令登陆,即使程序关闭,一定时间内重新开启也可以不用重新扫码。 diff --git a/README.rst b/README.rst index 35feea3a..65d643ad 100644 --- a/README.rst +++ b/README.rst @@ -71,6 +71,12 @@ Because of width of some character differs from systems, you may adjust the enab # for some linux system, width of block character is one instead of two, so enableCmdQR should be 2 itchat.auto_login(enableCmdQR = 2) +Default background color of command line is dark (black), if it's not, you may set enableCmdQR to be negative: + +.. code:: python + + itchat.auto_login(enableCmdQR = -1) + *Hot reload* By using the following command, you may reload the program without re-scan QRCode in some time. diff --git a/README_EN.md b/README_EN.md index edc8ba87..64b6306f 100644 --- a/README_EN.md +++ b/README_EN.md @@ -68,6 +68,12 @@ Because of width of some character differs from systems, you may adjust the enab itchat.auto_login(enableCmdQR = 2) ``` +Default background color of command line is dark (black), if it's not, you may set enableCmdQR to be negative: + +```python +itchat.auto_login(enableCmdQR = -1) +``` + ### Hot reload By using the following command, you may reload the program without re-scan QRCode in some time. diff --git a/itchat/tools.py b/itchat/tools.py index 55ebffb4..e8c64e74 100644 --- a/itchat/tools.py +++ b/itchat/tools.py @@ -63,7 +63,7 @@ def print_qr(fileDir): else: os.startfile(fileDir) try: - from PIL import Image + from PIL import Image def print_cmd_qr(fileDir, size = 37, padding = 3, white = BLOCK, black = ' ', enableCmdQR = True): img = Image.open(fileDir) @@ -71,11 +71,12 @@ def print_cmd_qr(fileDir, size = 37, padding = 3, rgb = img.convert('RGB') try: blockCount = int(enableCmdQR) - assert(0 < blockCount) + assert(0 < abs(blockCount)) except: blockCount = 1 finally: - white *= blockCount + white *= abs(blockCount) + if blockCount < 0: white, black = black, white sys.stdout.write(' '*50 + '\r') sys.stdout.flush() qr = white * (size + 2) + '\n'