|
| 1 | +from tkinter import * |
| 2 | + |
| 3 | +def submit(): |
| 4 | + getf=first.get() |
| 5 | + getl=last.get() |
| 6 | + geta=age.get() |
| 7 | + |
| 8 | + file=open('database.txt','a') |
| 9 | + file .write(getf+",",+getl+","+str(geta)+"\n") |
| 10 | + file.close() |
| 11 | + print("user registered") |
| 12 | + |
| 13 | + entry_first.delete(0,END) |
| 14 | + entry_last.delete(0,END) |
| 15 | + entry_age.delete(0,END) |
| 16 | + |
| 17 | +window=Tk() |
| 18 | +window.title("Registration Form") |
| 19 | +window.geometry("350x350") |
| 20 | + |
| 21 | +l1=Label(window, text="Please Register Now", bg="black", fg="white", font="times 12") |
| 22 | +l1.pack() |
| 23 | + |
| 24 | +first=StringVar() |
| 25 | +last=StringVar() |
| 26 | +age=IntVar() |
| 27 | + |
| 28 | +Label(window, text="First Name: ",bg="black", fg="white").place(x=50,y=60) |
| 29 | +entry_first=Entry(window,textvariable=first) |
| 30 | +entry_first.place(x=150,y=60) |
| 31 | + |
| 32 | +Label(window, text="Last Name: ",bg="black", fg="white").place(x=50,y=100) |
| 33 | +entry_last=Entry(window, textvariable=last) |
| 34 | +entry_last.place(x=150,y=120) |
| 35 | + |
| 36 | +Label(window, text="Age: ",bg="black", fg="white").place(x=50,y=1800) |
| 37 | +entry_age=Entry(window, textvariable=age) |
| 38 | +entry_age.place(x=150,y=1800) |
| 39 | + |
| 40 | +Button(window, text="Submit", bg="black", fg="white", font="times 12", command=submit).place(x=100,y=240) |
0 commit comments