Whenever I try running a function after pressing a button, rather than run the function, I get an error saying
Button(text = "Register", height = "2", width = "30", command = lambda : self.RegScreen()).pack() AttributeError: 'str' object has no attribute 'RegScreen'
I'm not sure what's causing this error or how I am meant to solve this. Below is the code I have used to far. Any help is greatly appreciated.
class Main:
def __init__(self, screen):
self.screen = Tk()
self.loginscreen = StringVar()
self.username = StringVar()
self.password = StringVar()
self.var_FName = StringVar()
self.var_SName = StringVar()
self.var_password1 = StringVar()
self.var_usertype = StringVar()
self.UserID = StringVar()
def main_screen(self):
#Main.addtohomeworkdb()
screen = Tk()
screen.geometry("300x250")
screen.title("Main Menu")
Label(text="Welcome to MyComputerScience!", bg="white", width="300", height="2", font=("Calibri", 13)).pack()
Label(text="").pack()
Button(text="Login", height="2", width="30", command=lambda: self.login).pack()
Label(text="").pack()
Button(text="Register", height="2", width="30", command=lambda: self.RegScreen).pack()
Label(text="").pack()
screen.mainloop()
def RegScreen(self):
print("bRuh")
if __name__ == '__main__':
Main.main_screen(self)