该程序应该问您一个链接,该链接由于代码中的某些事情而被转换为QRCode

发布于 2025-02-08 15:39:42 字数 1543 浏览 5 评论 0原文

该程序应该向用户询问一个输入,该输入将稍后用于创建QR码。有一个不起作用的按钮应该创建该QR码。之后,还有另一个按钮应该打开该QR码作为图像。

由于某种原因,我无法理解如何使用用户提供的输入。另外,QR码是在我什至做任何事情之前生成的。

import qrcode 
import tkinter
from PIL import Image



main = tkinter.Tk("Link converter to QrCode ")
main.title("Link converter to Qr Code")
main.geometry("685x85")

#This is used just for what the person should write on the side
link = tkinter.Label(
    main, 
    width="30",
    text=('Link:'))
link.grid(row=0)

#this entry is supposed to receive an input that will later be used
e1 = tkinter.Entry(
    main, 
    bd="5", 
    width="75",
    text=(""))
e1.grid(row=0, column=1)

#This is what should be getting the input from above
def retrieve_input():
    input = main.e1.get("1.0")
x=input



#This button is supposed to create the qrcode with the input given above
button_create = tkinter.Button(
    main, 
    text="Click to create the Qrcode.", 
    command = lambda: qrcode.make(x))
button_create.grid(row=2, column=1)

img = qrcode.make()
img.save ("Qrcode.png")



#This button should open the image of the qrcode
button_open = tkinter.Button ( 
    main,  
    text="Click here to open the Qrcode", 
    command = lambda: Image.open(open("Qrcode.png", "rb")),
    width="25")
button_open.grid(row=2, column=0)


#This button is working and is just to close the program
exit_button = tkinter.Button(
    main,
    width=("15"),
    text='Exit',
    command= lambda: main.quit())
exit_button.grid(row=3, column=0)


main.mainloop()

This program is supposed to ask the user for an input that will be later used to create a QR code. There's a button, which isn't working, that is supposed to create that QR code. After that, there is another button that is supposed to open that QR code as an image.

For some reason I can't understand how I am going to use the input the user gives. Also, the QR code is generated before I even do anything.

import qrcode 
import tkinter
from PIL import Image



main = tkinter.Tk("Link converter to QrCode ")
main.title("Link converter to Qr Code")
main.geometry("685x85")

#This is used just for what the person should write on the side
link = tkinter.Label(
    main, 
    width="30",
    text=('Link:'))
link.grid(row=0)

#this entry is supposed to receive an input that will later be used
e1 = tkinter.Entry(
    main, 
    bd="5", 
    width="75",
    text=(""))
e1.grid(row=0, column=1)

#This is what should be getting the input from above
def retrieve_input():
    input = main.e1.get("1.0")
x=input



#This button is supposed to create the qrcode with the input given above
button_create = tkinter.Button(
    main, 
    text="Click to create the Qrcode.", 
    command = lambda: qrcode.make(x))
button_create.grid(row=2, column=1)

img = qrcode.make()
img.save ("Qrcode.png")



#This button should open the image of the qrcode
button_open = tkinter.Button ( 
    main,  
    text="Click here to open the Qrcode", 
    command = lambda: Image.open(open("Qrcode.png", "rb")),
    width="25")
button_open.grid(row=2, column=0)


#This button is working and is just to close the program
exit_button = tkinter.Button(
    main,
    width=("15"),
    text='Exit',
    command= lambda: main.quit())
exit_button.grid(row=3, column=0)


main.mainloop()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

几度春秋 2025-02-15 15:39:42

获取条目的值,并将其用作参数qrcode.make()

将此代码放入retirevie_input()函数中,然后从按钮调用该代码。

#This is what should be getting the input from above
def retrieve_input():
    img = qrcode.make(e1.get())
    img.save("Qrcode.png")

#This button is supposed to create the qrcode with the input given above
button_create = tkinter.Button(
    main,
    text="Click to create the Qrcode.",
    command = retrieve_input)
button_create.grid(row=2, column=1)

Get the value of the entry and use it as the argument to qrcode.make().

Put this code into the retrieve_input() function, and call that from the button.

#This is what should be getting the input from above
def retrieve_input():
    img = qrcode.make(e1.get())
    img.save("Qrcode.png")

#This button is supposed to create the qrcode with the input given above
button_create = tkinter.Button(
    main,
    text="Click to create the Qrcode.",
    command = retrieve_input)
button_create.grid(row=2, column=1)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文