commit 57420fd030f72edfc73ae4a370cd18c92bf0fc16 Author: sairate Date: Sat May 24 17:06:00 2025 +0800 feat: 创建 QRCodeGenerator 项目 - 新增主程序文件 main.py 实现二维码生成功能 - 添加安装环境脚本 安装环境.py 以安装所需第三方库 - 创建 .idea 目录及相关配置文件,设置项目环境和忽略项 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/.idea/QRCodeGenerator.iml b/.idea/QRCodeGenerator.iml new file mode 100644 index 0000000..d9f5388 --- /dev/null +++ b/.idea/QRCodeGenerator.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..25bde2c --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..620852a --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..40cb4cc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fce20b3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..7e314e5 --- /dev/null +++ b/main.py @@ -0,0 +1,38 @@ +# 编程前,运行【安装第三方库.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() + diff --git a/qrcode_bg.png b/qrcode_bg.png new file mode 100644 index 0000000..0acc19f Binary files /dev/null and b/qrcode_bg.png differ diff --git a/安装环境.py b/安装环境.py new file mode 100644 index 0000000..18fe1f9 --- /dev/null +++ b/安装环境.py @@ -0,0 +1,7 @@ +import subprocess +import sys + +subprocess.check_call([ + sys.executable, "-m", "pip", "install", "amzqr", + "-i", "https://mirrors.aliyun.com/pypi/simple/" +])