0

I'm working on this simple project where I have this one entry on this Tkinter window and one button where this button functionality is to display an image from the entry input

from tkinter import *
from PIL import ImageTk, Image  
import tkinter as tk
window = Tk()
window.title("Color detector")
window.geometry("800x500")

input_img = tk.Entry(window)
input_img.pack()

def original_image():
    get_input_img = str(input_img.get())
    img =Image.open('C:\\users\\HP\\Documents\\' + get_input_img)
    bg = ImageTk.PhotoImage(img)

    resize_img = img.resize((400,300),Image.ANTIALIAS)
    new_img = ImageTk.PhotoImage(resize_img)
    # Add image
    label = Label(window, image=new_img)
    label.place(x = 0,y = 0)

reveal_img = tk.Button(window, text='Display Image',command=original_image)
reveal_img.pack()

# Execute tkinter
window.mainloop()

The thing is when I pressed the button the image won't display and the image invisibility covered the entry.

Original output:

enter image description here

Output after button is pressed:

enter image description here

Why does this occurs and how do I fix it?.

dan123
  • 121
  • 6

0 Answers0