-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathForm1-mod.py
118 lines (94 loc) · 3.6 KB
/
Form1-mod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from tkinter import *
import sqlite3
import tkinter.messagebox
window=Tk()
window.geometry("800x800")
window.title("User Registration Form")
fn=StringVar()
mn=StringVar()
ln=StringVar()
DOB=StringVar()
pro=StringVar()
num=StringVar()
cit=StringVar()
var=StringVar()
c1=StringVar()
def printt():
tkinter.messagebox.showinfo("Success", "Successfully Registered!\n \nYou can now click on EXIT to close the application.")
def exitt():
exit()
def database():
name1=fn.get()
name2=mn.get()
name3=ln.get()
date=DOB.get()
sex=c1.get()
contact=num.get()
city1=cit.get()
state1=var.get()
choice=pro.get()
conn=sqlite3.connect("Form.db")
with conn:
cursor=conn.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS Student(First TEXT,Middle TEXT,Last TEXT,DOB TEXT,Gender TEXT,Contact TEXT,City TEXT,State TEXT,Project TEXT)')
cursor.execute('INSERT INTO Student(First,Middle,Last,DOB,Gender,Contact,City,State,Project) VALUES (?,?,?,?,?,?,?,?,?)' , (name1,name2,name3,date,sex,contact,city1,state1,choice),)
conn.commit()
#HEADER
header=Label(window, text="User Registration", font=("Arial", 20), relief="solid")
header.place(x=280, y=10)
#ENTRYFIELD FOR FIRST NAME
firstname=Label(window, text="First Name : ", font=("Arial",14))
firstname.place(x=10, y=120)
field1=Entry(window,textvar=fn)
field1.place(x=140, y=123)
#ENTRYFIELD FOR MIDDLE NAME
firstname=Label(window, text="Middle Name : ", font=("Arial",14))
firstname.place(x=400, y=120)
field1=Entry(window, textvar=mn)
field1.place(x=550, y=123)
#ENTRYFIELD FOR LAST NAME
lastname=Label(window, text="Last Name : ", font=("Arial",14))
lastname.place(x=10, y=160)
field2=Entry(window,textvar=ln)
field2.place(x=140, y=163)
#ENTRY FIELD FOR DOB
dob=Label(text="Date of Birth : \n (DD/MM/YYYY) ", font=("Arial",14))
dob.place(x=0, y=200)
field3=Entry(window,textvar=DOB)
field3.place(x=150, y=210)
#ENTRY FIELD FOR GENDER
gender=Label(text="Gender: ", font=("Arial",14))
gender.place(x=400, y=210)
ch1=Radiobutton(window,text="Male", variable=c1, value="Male").place(x=500, y=210)
ch2=Radiobutton(window, text="Female", variable=c1, value="Female").place(x=570, y=210)
ch3=Radiobutton(window, text="Others", variable=c1, value="Others").place(x=650, y=210)
#ENTRYFIELD FOR CITY
city=Label(window, text="City : ", font=("Arial",14))
city.place(x=10, y=270)
field4=Entry(textvar=cit)
field4.place(x=100, y=275)
#ENTRYFIELD FOR STATE
state=Label(window, text="State : ", font=("Arial",14))
state.place(x=10, y=320)
list1=['Andhra Pradesh', 'Arunachal Pradesh','Assam','Bihar', 'Chattisgarh','Goa','Gujarat','Haryana','Himachal Pradesh','J&K','Jharkhand','Karnataka','Kerala','Madhya Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Odisha','Punjab','Rajasthan','Sikkim','Tamil Nadu','Telangana','Tripura','Uttar Pradesh','Uttarakhand','West Bengal']
droplist=OptionMenu(window, var,*list1)
var.set("Select State")
droplist.config(width=20)
droplist.place(x=100, y=320)
#ENTRYFIELD FOR CONTACT NO.
cont=Label(text="Contact No.: +91 - ", font=("Arial",14))
cont.place(x=10, y=390)
field5=Entry(textvar=num)
field5.place(x=200, y=395)
#ENTRYFIELD FOR PROJECT DESCRIPTION
proj=Label(text="Project Name: ", font=("Arial",14))
proj.place(x=10, y=460)
field6=Entry(window,textvar=pro)
field6.place(x=180, y=464)
#BUTTONS
but1 = Button(text=" Submit", width=12, height=2, bg="beige", font=("Arial", 8), command=lambda: [printt(), database()])
but1.place(x=100, y=650)
window.bind("<Return>", database)
but2=Button(text="Exit", width=12, height=2, bg="beige", font=("Arial",8), command=exitt)
but2.place(x=600, y=650)
window.mainloop()