-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
136 lines (109 loc) · 3.86 KB
/
Main.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
from tkinter import *
import tkinter as tk
from tkinter.messagebox import showwarning
import Controller.DAO as Conn
from Menu import HomePage
import User_ID
import Main
class main(tk.Tk):
def __init__(self):
super().__init__()
self.title("Login")
self.iconbitmap('assets/img/logo/logo.ico')
window_width = 1000
window_height = 600
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
center_x = int(screen_width/2 - window_width / 2)
center_y = int(screen_height/2 - window_height / 2)
self.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')
self.configure(bg = "#ffffff")
canvas = Canvas(
self,
bg = "#ffffff",
height = 600,
width = 1000,
bd = 0,
highlightthickness = 0,
relief = "ridge")
canvas.place(x = 0, y = 0)
background_img = PhotoImage(file = f"assets/img/login/background.png")
background = canvas.create_image(
470, 300,
image=background_img)
TextBox_ID_img = PhotoImage(file = 'assets/img/login/TextBox_ID.png')
TextBox_ID_bg = canvas.create_image(
745, 260,
image = TextBox_ID_img)
Tb_ID = Entry(
bd = 0,
bg = "#d8d8d8",
highlightthickness = 0)
Tb_ID.place(
x = 570, y = 232,
width = 350.0,
height = 59)
def Start_clicked():
input = Tb_ID.get()
if input == (""):
showwarning(title='Error',message='ID không được trống !')
else:
conn = Conn.connectDatabase()
cursor = conn.cursor()
sql = "select ID from user_ID where ID = {};".format(input)
#neu query toan bo ID thi de trong loop khong duoc vi no chi xet duoc 1 hang
#kieu tra ve cua sql la string ko so sanh voi int duoc nen phai so sanh ""
#
flag = True
for row in cursor.execute(sql):
if row.ID != (""):
flag = False
if flag == False:
self.destroy()
move = HomePage()
else:
showwarning(title='Error',message='ID không hợp lệ')
#
Button_Start = PhotoImage(file = f"assets/img/login/Button_Start.png")
Bt_Start = Button(
image = Button_Start,
borderwidth = 0,
highlightthickness = 0,
command = Start_clicked,
relief = "flat")
Bt_Start.place(
x = 663, y = 418,
width = 159,
height = 50)
def btn_Register():
self.destroy()
move = User_ID.Register()
Button_CreateID = PhotoImage(file = f"assets/img/login/Button_CreateID.png")
Bt_CreateID = Button(
image = Button_CreateID,
borderwidth = 0,
highlightthickness = 0,
command = btn_Register,
relief = "flat")
Bt_CreateID.place(
x = 845.5, y = 530,
width = 96,
height = 16)
def Fogot_clicked():
self.destroy()
move = User_ID.Fogot()
Button_Fogot = PhotoImage(file = f"assets/img/login/Button_Fogot.png")
Bt_Fogot = Button(
image = Button_Fogot,
borderwidth = 0,
highlightthickness = 0,
command = Fogot_clicked,
relief = "flat")
Bt_Fogot.place(
x = 850, y = 510,
width = 96,
height = 13)
self.resizable(False, False)
self.mainloop()
if __name__=="__main__":
start = main()