-
Notifications
You must be signed in to change notification settings - Fork 1
/
Login.py
105 lines (80 loc) · 3.43 KB
/
Login.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
import tkinter as tk
from tkinter import ttk
import Credentialsmatch as cm
import Client as Client
class login():
def __init__(self):
self.win=tk.Tk()
self.win.title("Employee Portal")
self.enterusername()
self.enterpassword()
self.loginbutton()
# entering username
def enterusername(self):
username=tk.StringVar()
ttk.Label(self.win, text="Username").grid(column=0, row=0)
self.username=ttk.Entry(self.win, width=20, textvariable=username)
self.username.grid(column=1, row=0, sticky='W')
#function for password
def enterpassword(self):
password= tk.StringVar()
ttk.Label(self.win, text="Password").grid(column=0, row=1)
self.password = ttk.Entry(self.win, width=20, textvariable=password)
self.password.grid(column=1, row=1, sticky='W')
# function that display login button
def loginbutton(self):
login=ttk.Button(self.win,text="Login", command=self.loginaction)
login.grid(column=0, row=3, columnspan=2)
def closesecond(self):
self.chat.destroy()
self.chat.quit()
self.win.destroy()
self.win.quit()
def get(self):
printlistbox=self.listbox.get('active')
print(printlistbox)
def sendchatfun(self):
chatreceive=self.chatreceive.get()
# function that is caled when login button clicked
def loginaction(self):
recvpassword=self.password.get()
recvusername=self.username.get()
#function called from another module to match credentials
x=cm.matchcredentials()
# 1 returned if credentials match
getreturn =x.matchingcredentials(recvusername,recvpassword)
if getreturn:
chatreceive=tk.StringVar()
#print(":login successfull")
# the main window is closed
self.win.state("withdrawn")
# -----------------------------------------------------------------------------
#another window opening showing the functions
#self.chat=tk.Toplevel(self.win)
#ttk.Label(self.chat, text="Chat").grid(column=0, row=0)
# self.chatreceive = ttk.Entry(self.chat, width=20, textvariable=chatreceive)
# self.chatreceive.grid(column=0, row=2)
# sendchat = ttk.Button(self.chat, text="Send", command=self.sendchatfun) # button calls the sendchat function
# sendchat.grid(column=1, row=2)
# self.chat.protocol('WM_DELETE_WINDOW', self.closesecond)
# -----------------------------------------------------------------------------
# scroll bar code that is going to display
# loginscroll = tk.Scrollbar(self.chat)
# self.listbox = tk.Listbox(self.chat)
# self.listbox.grid(column=0,row=1)
# for i in range(100):
# self.listbox.insert(tk.END,i)
# self.listbox.config(yscrollcommand=loginscroll.set)
# loginscroll.config(command=self.listbox.yview)
# ----------------------------------------------------------------------
#sendto = ttk.Button(self.chat, text="-->>", command=self.get)
#sendto.grid(column=1, row=1)
client=Client.clientcode()
client.clientcodemain(recvusername,recvpassword)
#function that quits the tkinter module
def _quit(self):
self.win.quit()
self.win.destroy()
exit()
log=login()
log.win.mainloop()