# 编程前,运行【安装第三方库.py】文件,安装本课用到的第三方库
import tkinter
from PIL import Image, ImageTk
from tkinter import filedialog
import os
from amzqr import amzqr
w = tkinter.Tk()
w.geometry("400x400")
w.resizable(0,0)
bg_image = Image.open("qrcode_bg.png")
bg_image = ImageTk.PhotoImage(bg_image)
bg_label = tkinter.Label(w, image=bg_image)
bg_label.pack()
t1 = tkinter.Text(w, font=("微软雅黑", 12),width=30,height=5)
t1.place(x=80, y=100)
t2 = tkinter.Text(w, font=("微软雅黑", 12),width=23,height=1)
t2.place(x=80, y=250)
def get_pic():
pic_path = filedialog.askopenfilename()
t2.delete("1.0", "end")
t2.insert("1.0", pic_path)
btn1 = tkinter.Button(w, text="浏览", font=("微软雅黑", 12), command=get_pic)
btn1.place(x=312, y=250, height=25)
def qr():
words = t1.get("1.0","end")
words = "".join(words.split('\n'))
picture = t2.get("1.0", "end")[:-1]
version, level, qr_name = amzqr.run(words=words, picture=picture, colorized=True)
os.system(qr_name)
btn2 = tkinter.Button(w, text="生成二维码", font=("微软雅黑", 15), command=qr)
btn2.place(x=80, y=300, width=250)
w.mainloop()