if filepath is found display image and if not found display notfound.jpg and delete the input field.Tried ifelse statements andcouldn't figure it out. I have another issue i am trying to learn to fix. i will be scanning a barcode and it is very long. i need to be able to get the character 16 through 33 from the user input and use that to look for the file in order to display the image. sorry if this confusing. thank you for the help.
from os import link
from tkinter import *
from PIL import Image, ImageTk
root = Tk()
root.attributes('-fullscreen', True)
root.title("Images")
root.iconbitmap(r'C:\Users\hadhikari\example\Takumi_Logo.ico')
def myClick(self):
link = r'C:\Users\\hadhikari\\Desktop\\scanpics\\'+ e.get()+'.jpg'
my_img = ImageTk.PhotoImage(Image.open(link))
my_label.configure(image=my_img)
my_label.image = my_img
e.delete(0, END)
e = Entry(root, width=50, bg='light blue', borderwidth=3)
e.pack()
e.insert(0, '')
e.focus_set()
e.bind('<Return>', myClick)
button_quit = Button(root, text='Exit Program', command=root.quit)
button_quit.pack()
my_label = Label()
my_label.pack(padx=5, pady=10)
frame = LabelFrame(root, padx=600, pady=400)
frame.pack(padx=600, pady=600)
root.mainloop()
Aucun commentaire:
Enregistrer un commentaire