· 7 years ago · Nov 18, 2018, 10:52 PM
1from tkinter import *
2import sqlite3
3
4root = Tk()
5root.geometry('500x500')
6root.title("Registration Form")
7
8Fullname = StringVar()
9Email = StringVar()
10var = IntVar()
11c = StringVar()
12var1 = IntVar()
13
14
15def database():
16 name1 = Fullname.get()
17 email = Email.get()
18 gender = var.get()
19 country = c.get()
20 prog = var1.get()
21 conn = sqlite3.connect('tennis.db')
22 with conn:
23 cursor = conn.cursor()
24 cursor.execute(
25 'CREATE TABLE IF NOT EXISTS Student (Fullname TEXT,Email TEXT,Gender TEXT,country TEXT,Programming TEXT)')
26 cursor.execute('INSERT INTO Student (FullName,Email,Gender,country,Programming) VALUES(?,?,?,?,?)',
27 (name1, email, gender, country, prog,))
28 conn.commit()
29
30
31label_0 = Label(root, text="Registration form", width=20, font=("bold", 20))
32label_0.place(x=90, y=53)
33
34label_1 = Label(root, text="FullName", width=20, font=("bold", 10))
35label_1.place(x=80, y=130)
36
37entry_1 = Entry(root, textvar=Fullname)
38entry_1.place(x=240, y=130)
39
40label_2 = Label(root, text="Email", width=20, font=("bold", 10))
41label_2.place(x=68, y=180)
42
43entry_2 = Entry(root, textvar=Email)
44entry_2.place(x=240, y=180)
45
46label_3 = Label(root, text="Gender", width=20, font=("bold", 10))
47label_3.place(x=70, y=230)
48
49Radiobutton(root, text="Male", padx=5, variable=var, value=1).place(x=220, y=230)
50Radiobutton(root, text="Female", padx=20, variable=var, value=2).place(x=290, y=230)
51
52label_4 = Label(root, text="City", width=20, font=("bold", 10))
53label_4.place(x=70, y=280)
54
55list1 = ['Africa', 'Nigeria', 'Iceland', 'Other'];
56
57droplist = OptionMenu(root, c, *list1)
58droplist.config(width=15)
59c.set('select your city')
60droplist.place(x=240, y=280)
61
62label_4 = Label(root, text="Skill Level", width=20, font=("bold", 10))
63label_4.place(x=85, y=330)
64var2 = IntVar()
65var3 = IntVar()
66
67Checkbutton(root, text="Beginner", variable=var1).place(x=200, y=330)
68
69Checkbutton(root, text="Intermiadiate", variable=var2).place(x=280, y=330)
70
71Checkbutton(root, text="Advanced", variable=var3).place(x=390, y=330)
72
73def printdatshoot():
74 newtk = Tk()
75 newtk.geometry('500x500')
76 conn = sqlite3.connect('tennis.db')
77 with conn:
78 cursor = conn.cursor()
79 cursor.execute("SELECT * FROM Student")
80 result = cursor.fetchone()
81 conn.commit()
82 for r in result:
83 Label(newtk, text=r)
84
85johy = Button(root, text='Submit', width=20, bg='brown', fg='white', command=database)
86johy.place(x=180, y=380)
87johy1 = Button(root, text='See all', width=20, bg='brown', fg='white', command=printdatshoot)
88johy1.place(x=180, y=400)
89
90root.mainloop()
91
92def printdatshoot():
93 newtk = Tk()
94 newtk.geometry('500x500')
95 conn = sqlite3.connect('tennis.db')
96 with conn:
97 cursor = conn.cursor()
98 cursor.execute("SELECT * FROM Student")
99 result = cursor.fetchone()
100 conn.commit()
101 for r in result:
102 Label(newtk, text=r)