I want the Pin variable which takes some input in class StartPage to be inherited by the class Options, but using any code that uses Pin variable for eg. print(Pin) gives an error NameError: name 'Pin' is not defined. Passing both StartPage and tk.Frame as parent to class Option generates the error TypeError Cannot create a consistent method resolution
order (MRO) for bases Frame, StartPage. Don't Judge me, as I am new to both Tkinter and OOP, any explained solution is highly appreciated.
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="Enter 4 digit pin", font=controller.title_font, fg="red")
label.pack(side="top", fill="x", pady=10)
Pin = tk.Entry(self, bd = 4, relief="groove", show="*", font=20, justify='center')
Pin.pack()
submit = tk.Button(self, text="Submit", width=12,font=tkfont.Font(size=12),command=lambda: controller.show_frame("Options"), cursor="hand2")
submit.pack()
class Options(tk.Frame,StartPage):
def __init__(self, parent, controller):
print(Pin)
tk.Frame.__init__(self, parent)
self.controller = controller
f1=tk.Frame(self)
f1.pack()
f2=tk.Frame(self)
f2.pack(side="bottom")
button1 = tk.Button(f1, text="Balance Inquiry",relief="flat", padx=30, justify='left', cursor="hand2", fg="red", font=tkfont.Font(size=10),
command=lambda: controller.show_frame("PageOne"))
button1.pack(side="left")
button2 = tk.Button(f1, text="Deposit",relief="flat", padx=50, justify='right', cursor="hand2", fg="red", font=tkfont.Font(size=10),
command=lambda: controller.show_frame("PageTwo"))
button2.pack(side="left")
button3 = tk.Button(f2, text="Withdraw",relief="flat", padx=50, justify='left', cursor="hand2", fg="red", font=tkfont.Font(size=10),
command=lambda: controller.show_frame("PageThree"))
button3.pack(side="left")
button4 = tk.Button(f2, text="Pin Change",relief="flat", padx=50, justify='right', cursor="hand2", fg="red", font=tkfont.Font(size=10),
command=lambda: controller.show_frame("PageFour"))
button4.pack(side="left")