And the function def is indented one level further than it should be. Your functions are declared under the init function and so are garbage collected when init exits, (after the buttons are first created). Also, use partial so send parameters to the function. I don't know what "e" is supposed to be because you never declare it anywhere. The following code assumes that you want to delete the text from the button when you select it, so the following code demonstrates how to do that.
from tkinter import * from functools import partial class App: def __init__(self,master): #Variables account_number = IntVar().set("") pin_number = StringVar() #Frames Main = Frame(master) Main.pack() Top = Frame(master, bd=2, relief=RIDGE,borderwidth=0,highlightthickness=0) Top.pack(side=TOP, fill=X,pady=36) Form = Frame(master,height=200) Form.pack(side=TOP) #Labels self.lbl_title = Label(Top,text = "FedUni Banking",font=("Arial",32)) self.lbl_title.pack() self.lbl_account = Label(Form,text = "Account Number / PIN",font=("Arial",11)) self.lbl_account.grid(row=0,sticky=E) #Textboxes self.tb_account = Entry(Form,width=13,textvariable=account_number,font=("Arial",15)) self.tb_account.grid(row=0,column=1,ipady=18) self.tb_pin = Entry(Form,width=13,show="*",textvariable=pin_number,font=("Arial",15)) self.tb_pin.grid(row = 0,column = 2,ipady=18) #Buttons this_row=1 this_column=0 ## store button instances in a dictionary instead of separate variables self.btn_dict={} ## use a for instead of repeating the sam code over and over, and over for btn_num in range(1, 11): if btn_num==10: btn_num=0 btn_instance = Button(Form,text=btn_num, width=20, height=7, command=partial(self.setit, btn_num)) ## send btn num to function btn_instance.grid(row=this_row, column=this_column) self.btn_dict[btn_num]=btn_instance this_column += 1 if this_column > 2: this_column=0 this_row += 1 self.btn_cancel = Button(Form,text="Cancel/Clear",bg="red",width=20,height=7,command =self.clear) self.btn_cancel.grid(row=4,column=0) ## self.btn_login = Button(Form,text="Login",bg="green",width=20,height=7,command = lambda:login()) ## self.btn_login.grid(row=4,column=2) #Functions def setit(self, num): print(num) self.btn_dict[num].config(text="") def set_text(self, text): widget = e.focus_get() if widget in e.entries: widget.insert(0, text) def clear(self): self.tb_pin.delete(0,END) root = Tk() root.title("FedUni Banking") root.geometry("440x640") app = App(root) root.mainloop()