Python: I am working on payroll managment and have problem with tkinter

I keep getting an error which says "AttributeError: 'Home' object has no attribute 'tk' " even though i have instatiated home in the end. I've tried creating home(tk.frame) and further chnaging the code but nothing is helping. I am unable to correct the error so any feedback/help would be much appreciated thankyou

this is part of my code.

import tkinter as tk
from tkinter import *

class Home():
    def __init__(self,parent):
        self.parent=parent
        self.container = Frame(self)   
        self.container.pack(side = "top", fill = "both", expand = True)  
        self.container.grid_rowconfigure(0, weight = 1) 
        self.container.grid_columnconfigure(0, weight = 1)
        self.frames = {}
        for F in (emplyoyee,Page1): 
            frame = F(self.container, self)
            self.frames[F] = frame  
            frame.grid(row = 0, column = 0, sticky ="nsew") 
   
        self.show_frame(employee)

    def show_frame(self, cont): 
        frame = self.frames[cont] 
        frame.tkraise()

class employee():
    def __init__(self,info,controller):
        self.controller=controller
        self.info=info
        info.title("Payslip Generation")
        info.geometry('1350x650+0+0')
        info.configure(background="snow")
       
        top1=Frame(info,width=1350,height=50,bd=8,bg="snow")        #Frame 1
        top1.pack(side=TOP,pady=(0,20))
        self.lbl=Label(top1,font=('Times New Roman',45,'bold'),text="Employee Payslip Generation",fg="black").pack()

        self.btn=Button(top1,text="page 1",command = lambda : controller.show_frame(Page1),font=('arial',16,'bold'),width=14,fg="red",bg="powder blue")
        self.btn.pack(side=TOP)

        
        self.canvas = Canvas(info, borderwidth=0, background="slate blue")    #Canvas 1
        self.top2 = Frame(self.canvas, width=600,height=500,bd=8,bg="azure")  #Frame 2
        self.top2.pack(side=TOP)
        vsb = Scrollbar(info, orient="vertical", command=self.canvas.yview)   #Code for Scrollbar
        self.canvas.configure(yscrollcommand=vsb.set)

        vsb.pack(side="right", fill="y")
        self.canvas.pack(side="left", fill="both", expand=True)
        self.canvas.create_window((270,270), window=self.top2, anchor="nw")

        self.top2.bind("<Configure>", lambda event, canvas=self.canvas: self.onFrameConfigure(canvas))

        self.populate(self.top2)

    def onFrameConfigure(self,canvas):
        canvas.configure(scrollregion=canvas.bbox("all"))

   
# --------------------------------------- labels ------------------------------------------
       
    def populate(self,top2):
        self.lblName=Label(self.top2,text="       Employee Name      ",font=('arial',16,'bold'),bd=20,fg="black",bg="light grey").grid(row=0,column=0,pady=(0,10))
        self.lblID=Label(self.top2,text="          Employee ID         ",font=('arial',16,'bold'),bd=20,fg="black",bg="light grey").grid(row=1,column=0,pady=(0,10))


class Page1: 
    def __init__(self,parent,controller):
        self.controller=controller
        label1 = Label(self, text ="Page 1", font = LARGEFONT) 
        label1.grid(row = 0, column = 4, padx = 10, pady = 10) 
   
        # button to show frame 2 with text 
        # layout2 
        button1=Button(self, text ="StartPage")
      
        # putting the button in its place  
        # by using grid 
        button1.grid(row = 1, column = 1, padx = 10, pady = 10) 

        
parent=tk.Tk()
e=Home(parent)
parent.mainloop()

the errors are :
Traceback (most recent call last):
  File "C:\Users\Lenovo\Desktop\Vrinda\project work.py", line 128, in <module>
    e=Home(parent)
  File "C:\Users\Lenovo\Desktop\Vrinda\project work.py", line 7, in __init__
    self.container = Frame(self)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3119, in __init__
    Widget.__init__(self, master, 'frame', cnf, {}, extra)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2561, in __init__
    BaseWidget._setup(self, master, cnf)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2530, in _setup
    self.tk = master.tk
AttributeError: 'Home' object has no attribute 'tk'


Read more here: https://stackoverflow.com/questions/64900427/python-i-am-working-on-payroll-managment-and-have-problem-with-tkinter

Content Attribution

This content was originally published by vrinda467 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: