-
Notifications
You must be signed in to change notification settings - Fork 1
/
teacherDash.py
266 lines (209 loc) · 13.6 KB
/
teacherDash.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
from tkinter import *
import tkinter.messagebox
#import mysql.connector
import pymysql
import random
from time import strftime
from PIL import Image,ImageTk
from student import Student
from markdash import Markss
#from sheet import MarkEntry
class Teacher:
def __init__(self,root):
self.root = root
#self.root = Tk()
#self.show_loading_marks()
self.root.geometry("1450x730+0+0")
self.root.overrideredirect(True)
self.root.title('Color Changer')
# List of colors
colors = ["#000000","#000426","#000848","#000C6A","#00108C","#0014AE","#0018D0"]
#colors = ["#ff5733", "#33ff57", "#3357ff", "#ff33a6", "#a633ff"]
# Function to change the background color
def change_color():
color = random.choice(colors) # Select a random color from the list
self.root.configure(bg=color) # Change the background color of the window
self.root.after(10000, change_color) # Call the change_color function after 300000ms (5 minutes)
# Call the change_color function to start changing the color
change_color()
#self.root.configure(bg="black")
self.root .title("Report Management System | Developed by LarksTeckHub")
#====================title================
self.icon_title = PhotoImage(file="images/logo.png")
desired_width = 100
desired_height = 50
self.icon_title = self.icon_title.subsample(int(self.icon_title.width() / desired_width), int(self.icon_title.height() / desired_height))
title= Label(self.root, text="TEACHERS AND SECRETORY DASHBOARD",image=self.icon_title,compound=LEFT, font=("times new roman",40,"bold"),bg="#010c48",fg="white",anchor="w",padx=20).place(x=0,y=0,relwidth=1,height=70)
#============btn_logout=====
#btn_history = Button(self.root,text="History",font=("times new roman",15,"bold"),bg="yellow",cursor="hand2").place(x=1150,y=10,height=50,width=150)
#========clock================
# Function to display time on the label
def time():
string = f"Welcome to Report Management System\t\t Date: {strftime('%d-%m-%Y')}\t\t Time: {strftime('%H:%M:%S')}" # Format the time string
self.lbl_clock.config(text=string) # Update the label with the current time
self.lbl_clock.after(1000, time) # Call the time function after 1000ms (1 second)
# Create a label for the clock
self.lbl_clock = Label(self.root, text="", font=("times new roman", 15), bg="#4d636d", fg="white")
self.lbl_clock.place(x=0, y=70, relwidth=1, height=30)
# Call the time function to start displaying the time
time()
#===========Left Menu==============
LeftMenu = Frame(self.root,bd=2,relief=RIDGE, bg="white")
LeftMenu.place(x=0,y=102,width=200,height=600)
# Assuming functions to retrieve user information from the database
def get_user_name():
# Replace this function with your code to fetch the user's name from the database
return "Francis" # Example user name
def get_user_role():
# Replace this function with your code to fetch the user's role from the database
return "DOS" # Example user role
# Placeholder for user's photo (Assumed as a box)
user_photo_placeholder = Label(LeftMenu, text="User Photo", bg="lightgray", height=10)
user_photo_placeholder.pack(side="top", fill="x")
# Retrieve user information from the database
user_name = get_user_name()
user_role = get_user_role()
# Label to display the user's name
label_user_name = Label(LeftMenu, text=f"User: {user_name}",bg="#4d636d", padx=5,font=("times new roman",16,"bold"))
label_user_name.pack(side="top", fill="x")
# Label to display the user's role
label_user_role = Label(LeftMenu, text=f"Role: {user_role}",bg="#4d636d", padx=5,font=("times new roman",16,"bold"))
label_user_role.pack(side="top", fill="x")
########################Buttons#############################################
self.icon_side = PhotoImage(file="images/side.png")
new_width, new_height = 25, 25 # Set the new dimensions
self.icon_side = self.icon_side.subsample(self.icon_side.width()// new_width, self.icon_side.height() // new_height)
#=========================BUTTONS===============================================
btn_students = Button(LeftMenu,text="Students",command=self.show_loading_student,image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
btn_marks = Button(LeftMenu,text="Marks Entry",command=self.show_loading_marks,image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
btn_viewStud = Button(LeftMenu,text="View Students",image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
btn_reportGeneration = Button(LeftMenu,text="",image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
btn_reportGenerat = Button(LeftMenu,text="",image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
btn_reportGenerat = Button(LeftMenu,text="",image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
btn_reportGenerat = Button(LeftMenu,text="",image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
################## SETTINGS####################################################
# Create a Menu for Settings dropdown
self.settings_menu = Menu(root, tearoff=0)
self.settings_menu.configure(font=("times new roman", 16, "bold")) # Apply the same font as the Settings button
self.settings_menu.add_command(label="Reset Password", font=("times new roman", 16, "bold")) # Apply font to dropdown items
self.settings_menu.add_command(label="Edit Profile", font=("times new roman", 16, "bold")) # Apply font to dropdown items
# Function to display the Settings dropdown
def show_settings_menu():
x = btn_settings.winfo_rootx() + btn_settings.winfo_width() # Adjust x-coordinate to place the menu on the right
y = btn_settings.winfo_rooty() + btn_settings.winfo_height()
self.settings_menu.post(x, y)
# Settings Button with dropdown
btn_settings = Button(LeftMenu, text="Settings", image=self.icon_side, compound=LEFT, padx=5, anchor="w", font=("times new roman", 16, "bold"), bg="white", bd=3, cursor="hand2", command=show_settings_menu)
btn_settings.pack(side=TOP, fill=X)
# Attach the dropdown menu to the Settings button
#btn_settings['menu'] = self.settings_menu
btn_logout = Button(LeftMenu,text="Logout",command=self.logout,image=self.icon_side,compound=LEFT,padx=5,anchor="w",font=("times new roman",16,"bold"),bg="white",bd=3,cursor="hand2").pack(side=TOP,fill=X)
#===============content==================
#################################################################
# Connect to the MySQL database
mydb = pymysql.connect(host="localhost",user="root",database="report")
# Create a cursor object to execute SQL queries
mycursor = mydb.cursor()
# Execute an SQL query to get the total number of student
mycursor.execute("SELECT COUNT(*) FROM student")
# Fetch the result of the query
result = mycursor.fetchone()
# Get the total number of student from the result
total_student = result[0]
# Display the total number of steudent
self.lbl_student = Label(self.root, text=f"Total Students\n{total_student}", bd=5, relief=RIDGE, bg="#33bbf9", fg="white", font=("goudy old style", 20, "bold"))
self.lbl_student.place(x=250, y=120, height=100, width=200)
#####################################################
# Connect to the MySQL database
mydb = pymysql.connect(host="localhost",user="root",database="report")
# Create a cursor object to execute SQL queries
mycursor = mydb.cursor()
# Execute an SQL query to get the total number of stuff
mycursor.execute("SELECT COUNT(*) FROM teacher")
# Fetch the result of the query
result = mycursor.fetchone()
# Get the total number of stuff from the result
total_stuff = result[0]
# Display the total number of stuff
self.lbl_stuff = Label(self.root, text=f"Total Stuff\n{total_stuff}", bd=5, relief=RIDGE, bg="#ff5722", fg="white", font=("goudy old style", 20, "bold"))
self.lbl_stuff.place(x=450, y=120, height=100, width=200)
##################################################################
# Connect to the MySQL database
mydb = pymysql.connect(host="localhost",user="root",database="report")
# Create a cursor object to execute SQL queries
mycursor = mydb.cursor()
# Execute an SQL query to get the total number of subject
mycursor.execute("SELECT COUNT(*) FROM subject")
# Fetch the result of the query
result = mycursor.fetchone()
# Get the total number of subject from the result
total_subject = result[0]
# Display the total number of subject
self.lbl_subject = Label(self.root, text=f"Total Subject\n{total_subject}", bd=5, relief=RIDGE, bg="#009688", fg="white", font=("goudy old style", 20, "bold"))
self.lbl_subject.place(x=650, y=120, height=100, width=200)
#################################################################
# Connect to the MySQL database
mydb = pymysql.connect(host="localhost",user="root",database="report")
# Create a cursor object to execute SQL queries
mycursor = mydb.cursor()
# Execute an SQL query to get the total number of term
mycursor.execute("SELECT COUNT(*) FROM term")
# Fetch the result of the query
result = mycursor.fetchone()
# Get the total number of term from the result
total_term = result[0]
# Display the total number of term
self.lbl_term = Label(self.root, text=f"Total Term\n{total_term}", bd=5, relief=RIDGE, bg="#607d8b", fg="white", font=("goudy old style", 20, "bold"))
self.lbl_term.place(x=850, y=120, height=100, width=200)
#########################################################
#########################################################
# Connect to the MySQL database
mydb = pymysql.connect(host="localhost",user="root",database="report")
# Create a cursor object to execute SQL queries
mycursor = mydb.cursor()
# Execute an SQL query to get the total number of user
mycursor.execute("SELECT COUNT(*) FROM user")
# Fetch the result of the query
result = mycursor.fetchone()
# Get the total number of user from the result
total_term = result[0]
# Display the total number of user
self.lbl_sales = Label(self.root, text=f"Total Users\n{total_term}", bd=5, relief=RIDGE, bg="#ffc107", fg="white", font=("goudy old style", 20, "bold"))
self.lbl_sales.place(x=1050, y=120, height=100, width=200)
#========footer================
lbl_footer = Label(self.root,text="Report Management System | Developed by LarksTeckHub \nFor any Technical Issue Contact: 0741789121",font=("times new roman",12),bg="#4d636d",fg="white").pack(side=BOTTOM, fill=X)
#########################################
def show_loading_student(self):
self.loading_label = Label(self.root, text="Loading...", font=("times new roman", 20, "bold"))
self.loading_label.pack()
self.root.after(1000, self.student_details) # After 30 seconds, show another window
def student_details(self):
self.loading_label.destroy()
self.new_window=Toplevel(self.root)
self.app=Student(self.new_window)
def show_loading_marks(self):
self.loading_label = Label(self.root, text="Loading...", font=("times new roman", 20, "bold"))
self.loading_label.pack()
self.root.after(1000, self.marks_details) # After 30 seconds, show another window
def marks_details(self):
self.loading_label.destroy()
self.new_window=Toplevel(self.root)
self.app=Markss(self.new_window)
#########################################
#def show_loading_marksB(self):
# self.loading_label = Label(self.root, text="Loading...", font=("times new roman", 20, "bold"))
# self.loading_label.pack()
# self.root.after(1000, self.marksBu_details) # After 30 seconds, show another window
#def marksBu_details(self):
# self.loading_label.destroy()
# self.new_window=Toplevel(self.root)
# self.app=Marks(self.new_window)
def logout(self):
logout = tkinter.messagebox.askyesno("Report Management System", "Confirm if you want to log out", parent=self.root)
if logout:
# Perform logout actions here (e.g., closing the window, resetting variables, etc.)
self.root.destroy()
if __name__=="__main__":
root=Tk()
ob = Teacher(root)
root.mainloop()