0

I am new to tkinter please help me to solve this problem

i have a created a function of frame and gave a arugument to display image on frame on clicking the home button but its not displaying

what i shd do now its not showing any error too

This is code has no classes

from tkinter import *
from tkinter import ttk
from PIL import Image,ImageTk 
import os 
import pickle 
import mysql.connector  as sql
from tkinter import messagebox

def click_home():
    """set to default home tab where details like no. of students, employees, department shows """

    home_frame = Frame(root)
    home_frame.place(x=120, y=105, height=440, width=910)

    home_dashboard_frame = ImageTk.PhotoImage(file=r'files\Sublime Light1.jpg')
    home_panel = Label(home_frame, image=home_dashboard_frame, bg="white")
    home_panel.pack(fill='both', expand='yes')

root = Tk()
root.geometry("1067x600")
root.title("Dashboard")
root.resizable(False, False) 
#root.iconbitmap('images\\logo.ico')

bg = ImageTk.PhotoImage(file="files\Dashboard1.jpg")
lbl_bg = Label(root,image=bg)
lbl_bg.place(x=0,y=0,relwidth=1,relheight=1)


home_r=Image.open('Pics\\home.png')
home_r=home_r.resize((50, 50), Image.ANTIALIAS)
home = ImageTk.PhotoImage(home_r)
home_button = Button(root, image=home,font=("yu gothic ui", 13, "bold"), relief=FLAT, activebackground="white", borderwidth=0, background="white", cursor="hand2",command=click_home)
home_button.place(x=40, y=113)


manage_r=Image.open('Pics\\manage.png')
manage_r=manage_r.resize((50, 50), Image.ANTIALIAS)
manage = ImageTk.PhotoImage(manage_r)
manage_button = Button(root, image=manage,font=("yu gothic ui", 13, "bold"), relief=FLAT, activebackground="white", borderwidth=0, background="white", cursor="hand2")
manage_button.place(x=38, y=205)

view_r=Image.open('Pics\\view.png')
view_r=view_r.resize((50, 50), Image.ANTIALIAS)
view = ImageTk.PhotoImage(view_r)
view_button = Button(root, image=view,font=("yu gothic ui", 13, "bold"), relief=FLAT, activebackground="white", borderwidth=0, background="white", cursor="hand2")
view_button.place(x=36, y=299)

setting_r = Image.open('Pics\\setting.png')
setting_r=setting_r.resize((50, 50), Image.ANTIALIAS)
setting = ImageTk.PhotoImage(setting_r)
setting_button = Button(root, image=setting,font=("yu gothic ui", 13, "bold"), relief=FLAT, activebackground="white", borderwidth=0, background="white", cursor="hand2")
setting_button.place(x=38, y=395)

exit_1_r=Image.open('Pics\\exit_button.png')
exit_1_r=exit_1_r.resize((50, 50), Image.ANTIALIAS)
exit_1 = ImageTk.PhotoImage(exit_1_r)
exit_button = Button(root, image=exit_1,font=("yu gothic ui", 13, "bold"), relief=FLAT, activebackground="white", borderwidth=0, background="white", cursor="hand2")
exit_button.place(x=37, y=490)

logout = ImageTk.PhotoImage(file='Pics\logout.png')
logout_button = Button(root, image=logout,font=("yu gothic ui", 13, "bold"), relief=FLAT, activebackground="white", borderwidth=0, background="white", cursor="hand2")
logout_button.place(x=940, y=56)



root.mainloop()

any edits you want do u can ........

Thanks

0 Answers0