I am creatig a log-in system in a tkinter.notebook tab and I need to update the tab to enter the actual program after the user enters its userName and its password and click a button
Im using python 3.7 and the lastest tkinter version
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)
This is the tab so far, the idea is that when the user enters 1 as user-name and a as password the tab updates itself
MainAppinherits fromTkbut it also has a master. Are you using multiple instances ofTk?