-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_attendance.py
144 lines (133 loc) · 3.93 KB
/
show_attendance.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
import pandas as pd
from glob import glob
import os
import tkinter
import csv
import tkinter as tk
from tkinter import *
def subjectchoose(text_to_speech):
def calculate_attendance():
Subject = tx.get()
if Subject=="":
t='Please enter the subject name.'
text_to_speech(t)
os.chdir(
f"C:\\Users\\patel\\OneDrive\\Documents\\E\\FBAS\\Attendance\\{Subject}"
)
filenames = glob(
f"C:\\Users\\patel\\OneDrive\\Documents\\E\\FBAS\\Attendance\\{Subject}\\{Subject}*.csv"
)
df = [pd.read_csv(f) for f in filenames]
newdf = df[0]
for i in range(1, len(df)):
newdf = newdf.merge(df[i], how="outer")
newdf.fillna(0, inplace=True)
newdf["Attendance"] = 0
for i in range(len(newdf)):
newdf["Attendance"].iloc[i] = str(int(round(newdf.iloc[i, 2:-1].mean() * 100)))+'%'
#newdf.sort_values(by=['Enrollment'],inplace=True)
newdf.to_csv("attendance.csv", index=False)
root = tkinter.Tk()
root.title("Attendance of "+Subject)
root.configure(background="black")
cs = f"C:\\Users\\patel\\OneDrive\\Documents\\E\\FBAS\\Attendance\\{Subject}\\attendance.csv"
with open(cs) as file:
reader = csv.reader(file)
r = 0
for col in reader:
c = 0
for row in col:
label = tkinter.Label(
root,
width=10,
height=1,
fg="yellow",
font=("times", 15, " bold "),
bg="black",
text=row,
relief=tkinter.RIDGE,
)
label.grid(row=r, column=c)
c += 1
r += 1
root.mainloop()
print(newdf)
subject = Tk()
# windo.iconbitmap("AMS.ico")
subject.title("Subject...")
subject.geometry("580x320")
subject.resizable(0, 0)
subject.configure(background="black")
# subject_logo = Image.open("UI_Image/0004.png")
# subject_logo = subject_logo.resize((50, 47), Image.ANTIALIAS)
# subject_logo1 = ImageTk.PhotoImage(subject_logo)
titl = tk.Label(subject, bg="black", relief=RIDGE, bd=10, font=("arial", 30))
titl.pack(fill=X)
# l1 = tk.Label(subject, image=subject_logo1, bg="black",)
# l1.place(x=100, y=10)
titl = tk.Label(
subject,
text="Which Subject of Attendance?",
bg="black",
fg="green",
font=("arial", 25),
)
titl.place(x=100, y=12)
def Attf():
sub = tx.get()
if sub == "":
t="Please enter the subject name!!!"
text_to_speech(t)
else:
os.startfile(
f"C:\\Users\\patel\\OneDrive\\Documents\\E\\FBAS\\Attendance\\{sub}"
)
attf = tk.Button(
subject,
text="Check Sheets",
command=Attf,
bd=7,
font=("times new roman", 15),
bg="black",
fg="yellow",
height=2,
width=10,
relief=RIDGE,
)
attf.place(x=360, y=170)
sub = tk.Label(
subject,
text="Enter Subject",
width=10,
height=2,
bg="black",
fg="yellow",
bd=5,
relief=RIDGE,
font=("times new roman", 15),
)
sub.place(x=50, y=100)
tx = tk.Entry(
subject,
width=15,
bd=5,
bg="black",
fg="yellow",
relief=RIDGE,
font=("times", 30, "bold"),
)
tx.place(x=190, y=100)
fill_a = tk.Button(
subject,
text="View Attendance",
command=calculate_attendance,
bd=7,
font=("times new roman", 15),
bg="black",
fg="yellow",
height=2,
width=12,
relief=RIDGE,
)
fill_a.place(x=195, y=170)
subject.mainloop()