【Python】 Generate QR code

created a program that uses python to create QR codes.
Below is an image of the resulting program.
Insert image description here

Function description

Enter a URL.
Enter the name of the QR code.
When the QR code generation button is clicked, the QR code will be generated as an image using the characters entered in QRname.

code

import qrcode
import tkinter

def btn_click():
    S = txt_1.get()
    qr_name = txt_2.get()
    img = qrcode.make(S)
    img.save(f'{
      
      qr_name}.png')

# 画面作成
tki = tkinter.Tk()
tki.geometry('460x190')
tki.title('生成二维码')

lbl_1 = tkinter.Label(text='URL')
lbl_1.place(x=70, y=50)

lbl_1 = tkinter.Label(text='QRname')
lbl_1.place(x=70, y=100)

txt_1 = tkinter.Entry(width=30)
txt_1.place(x=130, y=50)

txt_2 = tkinter.Entry(width=30)
txt_2.place(x=130, y=100)

# 按钮
btn = tkinter.Button(tki, text='生成二维码', command=btn_click)
btn.place(x=180, y=150)
tki.mainloop() # 启动应用程序

The actual created QR code is shown below.
Insert image description here

Guess you like

Origin blog.csdn.net/Allan_lam/article/details/134884714
Recommended