-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path二维码识别.py
38 lines (29 loc) · 900 Bytes
/
二维码识别.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from PIL import ImageGrab
from pyzbar import pyzbar
import tkinter as tk
import webbrowser
results: any
def grab():
img = ImageGrab.grab()
global results
results = pyzbar.decode(image=img, symbols=[pyzbar.ZBarSymbol.QRCODE])
urls = []
if len(results):
for result in results:
urls.append(result.data.decode('utf-8'))
label['text'] = urls
button0.pack()
else:
label['text'] = '未扫描到二维码'
def open_url():
for result in results:
webbrowser.open(url=result.data.decode('utf-8'))
win = tk.Tk()
win.title('米奇妙妙屋GUI版')
win.wm_attributes('-topmost', 1)
button = tk.Button(win, text='截屏二维码', command=grab)
label = tk.Label(win, text='结果')
button0 = tk.Button(win, text='打开网站', command=open_url)
button.pack()
label.pack()
win.mainloop()