The problem with this code is that , i know the actual .png file isnt corrupted , I've tested it multiple times in other projects , im not sure why my photo1
image isnt appearing inside of my Toplevel
window. Any Reason why this is occuring in my toplevel widget and how to fix it?
from tkinter import *
from tkinter import ttk
root = Tk()
#placing of the window
w = 600
h = 250
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
root.geometry('%dx%d+%d+%d' % (w,h,x , y))
#Window title
root.title(string= "Longwood Panther Math Game Main Menu")
#The window configuration
root.resizable(width = False , height = False)
#level variable
def language_Arts(a):
root.withdraw()
language_window = Toplevel()
language_window.iconbitmap('panther.ico')
#title
language_window.title(string = 'Language Arts Main Menu')
#placing of the window
w = 500
h = 250
ws = language_window.winfo_screenwidth()
hs = language_window.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
language_window.geometry('%dx%d+%d+%d' % (w,h,x , y))
#Greetings
Greetings =Message(language_window , text = 'Welcome to The Language Arts Section, this is Where you Can Brush up on Your Grammar , and improve gramatical errors. With Multiple levels based on your skill level(grade classification)' , font= 'times 10 bold')
Greetings.grid(row = 2 , column = 0 , sticky = 'we')
#elementary
elementary = ttk.Button(language_window , text = 'Elementary')
elementary.grid(row = 2 , column = 1 , sticky = 'we')
#middle school button
middleschool = ttk.Button(language_window ,text = 'Middle School')
middleschool.grid(row = 2 , column = 2 , sticky = 'we')
#highschool button
highschool = ttk.Button(language_window , text = 'High School')
highschool.grid(row = 2 , column = 3, sticky = 'we')
# photos
photo1 = PhotoImage(file = 'grammar-cartoon.png')
photo2 = PhotoImage(file ='Matt1-240x3005.png')
#image labels
image1 = Label(language_window , image = photo1)
image1.grid(row = 3 , column = 0 , sticky = 'we')
LA_Button = ttk.Button(root , text= 'Language Arts')
LA_Button.grid(row = 4 , column = 4, sticky = 'we')
LA_Button.bind('<Button-1>' , language_Arts)
root.mainloop()