I am having an issue with my data being entered gets saved wrong into my excel file.
i believe the issue relates to my insert function
User Name Password
Marvin Marvinpassword
arvin arvinpassword
rvin rvinpassword
vin vinpassword
in inpassword
n npassword
password
assword
ssword
sword
word
ord
rd
d
i cant seem to find the issue.Please help
Here is the full code
i believe the issue relates to my insert function
def insert(self) : current_row = sheet.max_row if (self.eUSER.get() == "" and self.ePASS.get() == "" ): print("empty input") return else : self.eUSER.focus_set() sheet.cell(row=current_row + 1, column=1).value = self.eUSER.get() sheet.cell(row=current_row + 1, column=2).value = self.ePASS.get() self.eUSER.bind("<Return>", self.focusU) self.ePASS.bind("<Return>", self.focusP) self.eUSER.grid(row=1, column=1, ipadx="100") self.ePASS.grid(row=2, column=1, ipadx="100") sheet.column_dimensions['A'].width = 40 sheet.column_dimensions['B'].width = 40 sheet.column_dimensions['C'].width = 40 sheet.cell(row=1, column=1).value = "User Name" sheet.cell(row=1, column=2).value = "Password" sheet.cell(row=1, column=3).value = "Security question" wb.save(r'C:\Users\Hennie\Desktop\new\sheet.xlsx') self.clear() self.eUSER.focus_set() self.insert() returnthis is my result
User Name Password
Marvin Marvinpassword
arvin arvinpassword
rvin rvinpassword
vin vinpassword
in inpassword
n npassword
password
assword
ssword
sword
word
ord
rd
d
i cant seem to find the issue.Please help
Here is the full code
import tkinter as tk from openpyxl import * wb = load_workbook(r'C:\Users\Hennie\Desktop\new\sheet.xlsx') sheet = wb.active # create new user class BuildApplication(tk.Frame): # Registration window def __init__(self, master=None): tk.Frame.__init__(self, master) self.current_row = sheet.max_row master.iconbitmap(r'C:\Users\Hennie\Desktop\new\logo.ico') self.grid() self.createWidgets() def createWidgets(self): self.lUSER = tk.Label(self, text="Username: ") self.lUSER.grid(row=1,column=2) self.eUSER = tk.Entry(self) self.eUSER.grid(row=2,column=2) self.lPASS = tk.Label(self, text="Password: ") self.lPASS.grid(row=3,column=2) self.ePASS = tk.Entry(self, show="*") self.ePASS.grid(row=4,column=2) self.LOGIN = tk.Button(self, text = "Create new user", fg="black", command =lambda :[self.setCredentials(), self.insert()]) self.LOGIN.grid(row=5,column=2) self.QUIT = tk.Button(self, text="QUIT", fg="black", command=self.master.destroy) self.QUIT.grid(row=6,column=2) def setCredentials(self): username = self.eUSER.get() password = self.ePASS.get() print("username", username) print("password", password) def focusU(self) : self.eUSER.focus_set() def focusP(self) : self.ePASS.focus_set() def clear(self) : self.eUSER.delete(0, ) self.ePASS.delete(0, ) def insert(self) : current_row = sheet.max_row if (self.eUSER.get() == "" and self.ePASS.get() == "" ): print("empty input") return else : self.eUSER.focus_set() sheet.cell(row=current_row + 1, column=1).value = self.eUSER.get() sheet.cell(row=current_row + 1, column=2).value = self.ePASS.get() self.eUSER.bind("<Return>", self.focusU) self.ePASS.bind("<Return>", self.focusP) self.eUSER.grid(row=1, column=1, ipadx="100") self.ePASS.grid(row=2, column=1, ipadx="100") sheet.column_dimensions['A'].width = 40 sheet.column_dimensions['B'].width = 40 sheet.column_dimensions['C'].width = 40 sheet.cell(row=1, column=1).value = "User Name" sheet.cell(row=1, column=2).value = "Password" sheet.cell(row=1, column=3).value = "Security question" wb.save(r'C:\Users\Hennie\Desktop\new\sheet.xlsx') self.clear() self.eUSER.focus_set() self.insert() return # Login Main window class SearchApplication(tk.Frame): ######################### # Login button ######################## def __init__(self, master=None): tk.Frame.__init__(self, master) self.grid() self.createWidgets() master.iconbitmap(r'C:\Users\Hennie\Desktop\new\logo.ico') def createWidgets(self): self.some_abel = tk.Label(self, text=" Eventually be the main page when you log in") self.some_abel.grid(row=1,column=1) self.quitb = tk.Button(self, text = "quit", fg="green", command=self.master.destroy ) self.quitb.grid(row=2,column=1) # Main window layout class MainApplication(tk.Frame): def __init__(self, master=None): tk.Frame.__init__(self, master) self.SaveUser = () self.grid() self.createWidgets() def createWidgets(self): #Save Data self.bBuild = tk.Button(self, text="Create new user", command=self.build) self.bBuild.grid(row=1,column=5) #login self.blogin = tk.Button(self, text="Login", command=self.login) self.blogin["text"] = "Login" self.blogin["command"] = self.login self.blogin.grid(row=2, column=1) #quit self.QUIT = tk.Button(self, text="QUIT", fg="red", command= self.master.destroy) self.QUIT.grid(row=3,column=1) def build(self): root2 = tk.Toplevel() buildApp = BuildApplication(master=root2) def login(self): root3 = tk.Toplevel() app2 = SearchApplication(master=root3) root = tk.Tk() app = MainApplication(master=root) app.configure(background='snow1') root.iconbitmap(r'C:\Users\Hennie\Desktop\new\logo.ico') app.master.geometry("500x300") app.master.title("North American Midway Entertainment") app.mainloop()