Я создаю графический интерфейс с tkinter, и у меня есть страница, на которой есть вход, когда вы входите в систему, она скрывает виджеты входа через .place_forget (), затем рисует кнопку, которая должна скрыть текущие виджеты, а затем перерисовать виджеты, объявленные в методе init
Я пытался просто позвонить init (), делая себя. init (), но я не выполняю работу
class logIn(ttk.Frame):
def __init__(self, *args,**kwargs):
super().__init__(*args,**kwargs)
self.userName=ttk.Entry(self)
self.userName.place(x=230,y=50)
self.userNameLabel=ttk.Label(self,text="User Name")
self.userNameLabel.place(x=120, y =50)
self.password= ttk.Entry(self)
self.password.place(x=230,y=100)
self.passwordLabel = ttk.Label(self, text="Password")
self.passwordLabel.place(x=120, y=100)
self.logIn=ttk.Button(self,text="Log In",command=self.getLoginInfo)
self.logIn.place(x=200,y=200)
def getLoginInfo(self):
userName=self.userName.get()
password=self.password.get()
logInList=[['1','a','0'],['2','b','1'],['3','c','0']]
login_success=False
migration_status=False
for user in logInList:
if userName == user[0]:
if password==user[1] and user[2]!='1':
login_success=True
migration_status=False
elif password==user[1] and user[2]=='1':
messagebox.showinfo("Access denied","User with migration issues")
login_success=False
migration_status=True
if not login_success and not migration_status:
messagebox.showinfo("Access denied", "Wrong User Name or password")
elif login_success and not migration_status:
for child in self.winfo_children():
child.place_forget()
self.draw_recervation()
self.userName.delete(0, tk.END)
self.password.delete(0, tk.END)
def draw_recervation(self):
self.searchKey=[]
self.countryList = ttk.Combobox(self, state="readonly")
self.countryList["values"] = ["1", "2", "3"]
self.countryList.bind("<<ComboboxSelected>>", self.updateCitiesOnSelection)
self.countryList.place(x=250, y=50)
self.countryListLabel=ttk.Label(self,text="Countries")
self.countryListLabel.place(x=100,y=50)
self.cityList = ttk.Combobox(self, state="readonly")
self.cityList.bind("<<ComboboxSelected>>", self.selectCityAndUpdateRoutes)
self.cityList.place(x=250, y=100)
self.cityListLabel=ttk.Label(self,text="Cities")
self.cityListLabel.place(x=100, y = 100)
self.routeList = ttk.Combobox(self, state="readonly")
self.routeList.bind("<<ComboboxSelected>>", self.getRoute)
self.routeList.place(x=250, y=150)
self.routeListLabel=ttk.Label(self, text="Routes")
self.routeListLabel.place(x=100,y=150)
self.backButton=ttk.Button(self, text="back", command=self.backToLogIn)
self.backButton.pack()
def backToLogIn(self):
for child in self.winfo_children():
child.place_forget()
#this is the method call I tried
self.__init__()