Skip to content

Commit

Permalink
色块反色
Browse files Browse the repository at this point in the history
我的控制台背景是白的...
  • Loading branch information
tempdban authored and littlecodersh committed Jul 31, 2016
1 parent 8913299 commit 604b6b0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ itchat.auto_login(enableCmdQR = True)
itchat.auto_login(enableCmdQR = 2)
```

默认控制台背景色为暗色(黑色),若背景色为浅色(白色),可以将enableCmdQR赋值为负值:

```python
itchat.auto_login(enableCmdQR = -1)
```

### 退出程序后暂存登陆状态

通过如下命令登陆,即使程序关闭,一定时间内重新开启也可以不用重新扫码。
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions itchat/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ 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)
times = img.size[0] / (size + padding * 2)
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'
Expand Down

0 comments on commit 604b6b0

Please sign in to comment.