· 8 years ago · Aug 22, 2018, 07:40 PM
1from Tkinter import *
2import subprocess
3import sqlite3
4from sqlite3.dbapi2 import Cursor
5
6
7class Start():
8 def __init__(self):
9 self.root = Tk()
10 self.root.geometry("300x200")
11 self.root.title("chat")
12 self.leb = Label(self.root, text="username:")
13 self.leb.place(x=20, y=20)
14 self.net = Label(self.root, text="password:")
15 self.net.place(x=20, y=40)
16 self.ley = Entry(self.root, )
17 self.ley.place(x=80, y=25)
18 self.ley2 = Entry(self.root, show="*")
19 self.ley2.place(x=80, y=45)
20 self.butt = Button(self.root, text="login", command=self.checkLogindata)
21 self.butt.place(x=165, y=95)
22 self.butt2 = Button(self.root, text="registration", command=self.registration)
23 self.butt2.place(x=15, y=95)
24 mainloop()
25
26 def registration(self):
27 self.root2 = Tk()
28 self.root2.geometry("400x200")
29 self.eny3 = Label(self.root2, text="first name")
30 self.eny3.place(x=20, y=20)
31 self.eny3 = Label(self.root2, text="lest name")
32 self.eny3.place(x=20, y=40)
33 self.eny3 = Label(self.root2, text="email")
34 self.eny3.place(x=20, y=60)
35 self.eny3 = Label(self.root2, text="password")
36 self.eny3.place(x=20, y=80)
37 self.eny3 = Label(self.root2, text="second password")
38 self.eny3.place(x=20, y=100)
39 self.br1 = Entry(self.root2)
40 self.br1.place(x=80, y=20)
41 self.br2 = Entry(self.root2)
42 self.br2.place(x=80, y=40)
43 self.br3 = Entry(self.root2)
44 self.br3.place(x=80, y=60)
45 self.br4 = Entry(self.root2, show="*")
46 self.br4.place(x=80, y=80)
47 self.br5 = Entry(self.root2, show="*")
48 self.br5.place(x=120, y=100)
49 self.butt3 = Button(self.root2, text="register", command=self.checkregisterion)
50 self.butt3.place(x=195, y=150)
51
52 def checkregisterion(self):
53 firstname = self.br1.get()
54 lesttname = self.br2.get()
55 email = self.br3.get()
56 password = self.br4.get()
57 password2 = self.br5.get()
58 self.conn = sqlite3.connect("myweb.db")
59 self.c = self.conn.cursor()
60 #names1 = [self.br1.get(), self.br2.get(), self.br3.get(), self.br4.get(), self.br5.get()]
61
62 self.c.execute(
63 '''create table if not exists michael2(id integer primary key autoincrement, firstname varchar(100),lestname varchar(200), email varchar(200),password varchar(200),scuondpasssowrd varchar(200))''')
64
65 self.c.execute("insert into michael2(firstname,lestname,email,password,scuondpasssowrd) values " + str((firstname,lesttname,email,password,password2)))
66
67 sql = "select * from michael2"
68 self.c.execute(sql)
69 ssss = self.c.fetchall()
70 for u in ssss:
71 print u
72 self.conn.commit()
73
74 def checkLogindata(self):
75 userlog = self.ley.get()
76 passwordlog = self.ley2.get()
77 self.conn2 = sqlite3.connect("myweb.db")
78 self.cc = self.conn2.cursor()
79 fe="select * from michael2 WHERE firstname "
80 print userlog
81 da = self.cc.execute(fe +userlog)
82
83 print da
84
85
86f = Start()
87
88
89def main():
90 f
91main()