Skip to content

Commit

Permalink
trying fix img.show()
Browse files Browse the repository at this point in the history
  • Loading branch information
J1uShan9 committed Jun 25, 2024
1 parent c47a4d7 commit 1c242fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions util/Data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from Crypto.Util.Padding import pad, unpad
from inquirer.themes import GreenPassion
from loguru import logger
from qrcode import QRCode # type: ignore
import qrcode


class CustomThemes(GreenPassion):
Expand Down Expand Up @@ -43,18 +43,16 @@ def JsonpToDict(self, data: str) -> dict:
return json.loads(json_str)

@logger.catch
def QRGenerate(self, url: str, img_path: str) -> None:
def QRGenerate(self, url: str) -> None:
"""
生成二维码
url: 链接
img_path: 保存路径
"""
qr = QRCode()
qr = qrcode.QRCode()
qr.add_data(url)

img = qr.make_image()
img.save(img_path)

try:
parent_pid = psutil.Process(os.getpid()).ppid()
Expand All @@ -68,7 +66,7 @@ def QRGenerate(self, url: str, img_path: str) -> None:
if os.name == "nt":
if parent_name == "powershell.exe" or "WT_SESSION" in os.environ:
qr.print_ascii(invert=True)
elif parent_name == "cmd.exe" or len(argv) == 1 and not argv[0].endswith(".py"):
elif parent_name == "cmd.exe" or argv[0].endswith(".exe"):
img.show()
else:
qr.print_ascii(invert=True)
Expand Down
2 changes: 1 addition & 1 deletion util/Login/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def QRCode(self) -> dict:

if resp["code"] == 0:
url = resp["data"]["url"]
self.data.QRGenerate(url, "qr.jpg")
self.data.QRGenerate(url)

t = 0
while True:
Expand Down

0 comments on commit 1c242fb

Please sign in to comment.