tkinter PhotoImage image not showing

Viewed 12

Hello everyone!
recently,I have been building an app to generate and display a qr code.The QR code does indeed generate and save in the directory of the app.But the thing is that when Tkinter reads the photo of the qr code,It just returns a blank image.Here is the code to my app:

from tkinter import *
from tkinter import PhotoImage
import qrcode
root = Tk()
root.title('qrcode generator')
root.config(background = 'black')
entry = Entry(width = 100 , font = ('sans serif' , '15' , 'bold'))
label = Label(root)
def generate():
        text = str(entry.get())
        code = qrcode.make(str(text))
        code.save('qrcode.png')
        img = PhotoImage(file = 'qrcode.png')
        label.config(image = img)
        label.pack()
submit = Button(text = 'submit' , command = generate)
entry.pack()
label.pack()
submit.pack()
root.mainloop()

and here is the output after clicking the 'submit' button: enter image description here

can anyone help plz?

0 Answers
Related