Я хочу, чтобы переменная Pin
, которая принимает некоторые данные в классе StartPage
, была унаследована классом Options
, но с использованием любого кода, который, например, использует переменную Pin
. print(Pin)
выдает ошибку NameError: name 'Pin' is not defined
. Передача StartPage
и tk.Frame
в качестве родителя в класс Option
приводит к ошибке TypeError Cannot create a consistent method resolution
order (MRO) for bases Frame, StartPage
. Не судите меня, так как я новичок в Tkinter и OOP, любое объясненное решение высоко ценится.
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")