I am trying to select a photo from my computer and open it in my program. I can search and select it safely wihout importing ImageTk,Image but when I import the ImageTk,Image the program is not even opening. Is there another way? If there is not can you tell me an alternative of ImageTk,Image. I tried to uninstall Pillow and install back. I tried Pillow 7.0.0 and 8.0.0 both of theese supposed to work with my python 3.8.5, I couldn't find or understand the problem. I tried to use both conda and original python paths from Vscode, nothing changed. I don't know but maybe libraries are blocking themselves etc. If you know anything this is important for me. Thx from now.
***Problem section:***
from os import defpath
from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
from PIL import ImageTk,Image
bruh_filename = filedialog.askopenfilename(initialdir = "D:/steam_apps")
windows2 = Toplevel()
my_image = ImageTk.PhotoImage(bruh_filename)
my_image_label = Label(windows2, Image = my_image).pack()
#########################################
***Full Code:***
from os import defpath
from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
from PIL import ImageTk,Image
root = Tk()
root.geometry("400x400")
root.iconbitmap("favicon.ico")
root.title("NSDMR.X")
#im2 = PhotoImage(file="giphy.gif")
#back = Label(root, image=im2)
#back.pack()
username = "Enes"
age = "19"
blood = "0Rh+"
password = "Bruh"
label1 = Label(root, text="hoş geldiniz.")
label1.pack()
username_l = Label(root, text="Lütfen kullanıcı adını girin.")
username_l.pack()
response = Entry(root)
response.pack()
age_l = Label(root, text="Lütfen yaşınızı girin.")
age_l.pack()
response2 = Entry(root)
response2.pack()
blood_l = Label(root, text="Lütfen kan grubunuzu girin.")
blood_l.pack()
response3 = Entry(root)
response3.pack()
password_l = Label(root, text="Lütfen parolayı girin.")
password_l.pack()
response4 = Entry(root)
response4.pack()
MODES = [
("Rocky Road to London.", "Rocky Road to London."),
("Rocky Road to Dublin.", "Rocky Road to Dublin."),
("Rocky Road to Mexico.", "Rocky Road to Mexico."),
]
Rocky = StringVar()
#Rocky.set("Rocky Road to Mexico.")
for text, mode in MODES:
Radiobutton(root, text=text, variable=Rocky, value=mode).pack()
#ImageTk.PhotoImage
def loginbruh():
if response.get() == username and response2.get() == age and response3.get() == blood and response4.get() == password and Rocky.get() == "Rocky Road to Dublin.":
messagebox.showinfo("Bilgilendirme", "Doğru girdiniz.")
bruh_filename = filedialog.askopenfilename(initialdir = "D:/steam_apps")
windows2 = Toplevel()
my_image = ImageTk.PhotoImage(file=bruh_filename)
print(bruh_filename)
#my_image_label = Label(windows2, image = my_image).pack()
else:
messagebox.showwarning("Bilgilendirme", "Yanlış girdiniz. Programdan çıkışınız yapılıyor!")
root.quit()
login_button = Button(root, text="Giriş", command=loginbruh)
login_button.pack()
im = PhotoImage(file="red_cross.png")
exit_button = Button(root, image = im, width=64, height=64, command=root.quit)
exit_button.pack()
root.mainloop()