I am using Tkinter fame based classes for navigation and i want to use image as logo in that I want to use a picture on a label frame but when i am using label frame and putting the picture on the application it is showing noting i have tried with different formats like jpeg and png but it is not working any where.
my main class which makes navigation possible
import tkinter as tk
import startPage
class tkinterApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
self.frames = {}
self.geometry(geometry)
self.attributes("-fullscreen", True)
StartPage=startPage.StartPage
for F in (StartPage):
frame = F(container, self)
self.frames[F] = frame
frame.config(bg="white")
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(startPage.StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
if hasattr(frame, 'refresh'):
frame.refresh()
frame.tkraise()
def get_page(self, page_class):
return self.frames[page_class]
if __name__ == "__main__":
app = tkinterApp()
app.mainloop()
the frame/class where i want to use photo.
import tkinter as tk
from tkinter import IntVar, ttk, CENTER, StringVar
import tkinter as tk
import PIL
from PIL import Image, ImageTk
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
image = Image.open("Photo.png") #image path
image = image.resize((50, 50), Image.ANTIALIAS)
logo = ImageTk.PhotoImage(image)
label = tk.Label(self, image=logo,bg ="white")
label.grid(row=0, column=0)
please help me if anyone knows my it is not working Thanks!