from tkinter import *
from tkinter import messagebox
addPupil = Tk()
addPupil.geometry("275x200")
addPupil.title("Add Pupil")
Label(text = "Add New Pupil", width = 30).grid(columnspan = 3)
x = 1
y = 0
entryboxNames = ["First Name", "Last Name", "School Name", "Guardian Name", "Gender"]
for i in range(5):
Label(text = entryboxNames[i]).grid(row = x, column = y)
ent = Entry()
Entry().grid(row = x, column = y + 1)
x = x + 1
def save():
file = open("details.txt", "a")
file.write(entryboxNames[i] + ":" + ent.get() + " " + "\n\n")
messagebox.showinfo("Saved", "Data saved")
file.close
save = Button(text = "Save", command = save).grid(row = 6, column = 0)
for some reason this code isnt saving data to the file, all i can see is the final term (gender) with nothing after it even if anyone enters something
0 comments:
Post a Comment
Thanks