from tkinter import*
import pyodbc
root = Tk()
root.geometry('500x500')
root.title("Registration Form")
root.configure(background = "red")
label_0 = Label(root, text="Registration form",width=20,font=("bold", 20),background = "white")
label_0.place(x=90,y=53)
label_1 = Label(root, text="FullName",width=20,font=("bold", 10),background = "white")
label_1.place(x=80,y=130)
entry_1 = Entry(root)
entry_1.place(x=240,y=130)
label_2 = Label(root, text="Email",width=20,font=("bold", 10),background = "white")
label_2.place(x=68,y=180)
entry_2 = Entry(root)
entry_2.place(x=240,y=180)
label_3 = Label(root, text="Gender",width=20,font=("bold", 10),background = "white")
label_3.place(x=70,y=230)
var = IntVar()
Radiobutton(root, text="Male",padx = 5, variable=var, value=1,background = "white").place(x=235,y=230)
Radiobutton(root, text="Female",padx = 20, variable=var, value=2,background = "white").place(x=290,y=230)
label_4 = Label(root, text="Age:",width=20,font=("bold", 10),background = "white")
label_4.place(x=70,y=280)
entry_3 = Entry(root)
entry_3.place(x=240,y=280)
label_5 = Label(root, text="Address:",width=20,font=("bold", 10),background = "white")
label_5.place(x=70,y=320)
entry_4 = Entry(root)
entry_4.place(x=240,y=320)
def add_data():
global entry_1
global entry_2
global var
conn=pyodbc.connect('DRIVER={SQL Server};SERVER=DESKTOP-0DBE93F;DATABASE=Employee;Trusted_Connection=yes;')
mycursor=conn.cursor()
mycursor.execute("INSERT INTO gender(name,email,gender) Values(?,?,?)",
(
entry_1.get(),
entry_2.get(),
var.get(),
))
conn.commit()
conn.close()
Button(root, text='Submit Form',width=20,bg='white',fg='black',command=add_data).place(x=180,y=380)
root.mainloop()
print("registration form seccussfully created...")













0 Comments