Я создаю систему входа на вкладке tkinter.notebook, и мне нужно обновить вкладку, чтобы войти в актуальную программу после того, как пользователь введет свое имя пользователя и пароль и нажмет кнопку
Я использую Python 3.7 и последнюю версию tkinter
import tkinter as tk
from tkinter import ttk
class MainApp(ttk.Frame):
def __init__(self,main_window):
super().__init__(main_window)
main_window.title("User")
self.notebook = ttk.Notebook(self,height=600,width=500)
self.reservation_page=reservaiones(self.notebook)
self.notebook.add(self.reservation_page,text="Reservations",padding=10)
self.notebook.pack(padx=10, pady=10)
self.pack()
class reservaiones(ttk.Frame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.userName=tk.Entry(self)
self.userName.place(x=100,y=50)
self.userNameLabel=tk.Label(self,text="User Name")
self.userNameLabel.place(x=20, y =50)
self.password= tk.Entry(self)
self.password.place(x=100,y=100)
self.userNameLabel = tk.Label(self, text="Password")
self.userNameLabel.place(x=20, y=100)
self.logIn=tk.Button(self,text="Log In",command=self.getLoginInfo)
self.logIn.place(x=100,y=200)
def getLoginInfo(self):
userName=self.userName.get()
password=self.password.get()
# Change this for the actual user list
logInList=[['1','a','0'],['2','b','1'],['3','c','0']]
for user in logInList:
if userName==user[0]:
if password==user[1] and user[2]!='1':
continue
elif password==user[1] and user[2]=='1':
self.migration=tk.Label(self,text="User with migration issues")
self.migration.place(x=50,y=150)
else:
self.wrongUserPassword = tk.Label(self, text="Access denied, wrong User Name or Password")
self.wrongUserPassword.place(x=2, y=150)
else:
self.wrongUserPassword = tk.Label(self, text="Access denied, wrong User Name or Password")
self.wrongUserPassword.place(x=2, y=150)
break
self.userName.delete(0,tk.END)
self.password.delete(0,tk.END)
Пока это вкладка, идея в том, что когда пользователь вводит 1 в качестве имени пользователя и пароль в качестве пароля, вкладка обновляется сама