该程序应该问您一个链接,该链接由于代码中的某些事情而被转换为QRCode
该程序应该向用户询问一个输入,该输入将稍后用于创建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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
获取条目的值,并将其用作参数
qrcode.make()
。将此代码放入
retirevie_input()
函数中,然后从按钮调用该代码。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.