I have been trying to call the function showframe which takes two aurgument. When i call it from Button command in HomePage it shows an error. TypeError: showframe() missing 1 required positional argument: 'frame_name'. I can't understand why? As I called by class name so it should automatically get self, then frame_name will get the SignIn class. But thats not happening.
class Culpture(Frame):
def __init__(self, root):
Frame.__init__(self, root)
fhome = HomePage(root)
fsignin = SignIn(root)
self.showframe(fhome)
fhome.grid(row=0, column=0, sticky='nsew')
fsignin.grid(row=0, column=0, sticky='nsew')
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
def showframe(self, frame_name):
frame_name.tkraise()
class HomePage(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
Label(self, text="Homepage").grid()
Button(self, text='SignIn', command=lambda: Culpture.showframe(SignIn), width=20).grid()
If I do this way,
Button(self, text='SignIn', command=lambda: Culpture.showframe(parent, SignIn), width=20).grid()
then it shows another error message.TypeError: tkraise() missing 1 required positional argument: 'self' So I tried to look some question I got one which is close to my solutionPython/Tkinter Event Argument Issue
but not same. If I try another way
Button(self, text='SignIn', command=lambda: Culpture.showframe(parent, SignIn(parent)), width=20).grid()
then it shows no error but button does not open the new frame.
class SignIn(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
Label(self, text="SignIn").grid()
Button(self, text='Submit', width=20).grid()
So it would be really helpfull if any of you can help me out.