/
pesuapp.py
186 lines (124 loc) · 5.19 KB
/
pesuapp.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
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 11:05:28 2019
@author: vishal
"""
import tkinter
import datetime
import re
from functools import partial
from dbcreate import *
from tk2 import *
def addCourse():
addCourseWin = tkinter.Tk()
addCourseWin.title("Add a course")
global addCourseLabel
addCourseLabel = tkinter.StringVar()
global addCourseEntry
tkinter.Label(addCourseWin, text="Course : ").pack()
addCourseEntry = tkinter.Entry(addCourseWin)
addCourseEntry.pack()
#print(addCourseEntry.get()
addCourseLabel = addCourseEntry
tkinter.Label(addCourseWin, text="").pack()
tkinter.Button(addCourseWin, text="Submit", width=10, height=1, command = checkAdd).pack()
def checkAdd():
print(addCourseLabel.get())
addcoursefac(addCourseLabel.get(),usernames)
def viewCourse():
viewWin = tkinter.Tk()
viewWin.title("Your courses")
courseList = getcoursesfac(usernames)
for i in courseList:
var = tkinter.Button(viewWin, text=i, command=partial(facAttendance,i), bg='gray', fg='white', height="2", width="25")
var.pack()
def submitBtn(i):
print(fromDate.get(),toDate.get())
date1 = fromDate.get().split('/')
date2 = toDate.get().split('/')
x = datetime.date(int(date1[2]),int(date1[1]),int(date1[0]))
y = datetime.date(int(date2[2]),int(date2[1]),int(date2[0]))
madattendance(x,i,y) #x - the from date and y - to date . course = name of course whose attendance we're seeing
def facAttendance(course):
attWin = tkinter.Tk()
attWin.title(course)
global fromDate
global toDate
global tbFrom
global tbTo
fromDate = tkinter.StringVar()
toDate = tkinter.StringVar()
fDt = tkinter.Label(attWin, text = "Enter front date in the following textbox as (d/m/y)")
fDt.pack()
tbFrom = tkinter.Entry(attWin)
tbFrom.pack()
fromDate = tbFrom
tDt = tkinter.Label(attWin, text = "Enter to date in the following textbox as (d/m/y)")
tDt.pack()
tbTo = tkinter.Entry(attWin)
tbTo.pack()
toDate = tbTo
submit = tkinter.Button(attWin, text='Submit',
command=partial(submitBtn,course), bg='red', fg='white', height="2", width="25")
submit.pack()
def faculty(usernames1):
global usernames
usernames=usernames1
mainWin = tkinter.Tk()
mainWin.title("Faculty Window")
hello = tkinter.Label(mainWin, text='Faculty')
hello.pack()
viewBtn = tkinter.Button(mainWin, text='View courses',
command=viewCourse, bg='red', fg='white', height="2", width="25")
viewBtn.pack()
courses = tkinter.Button(mainWin, text='Add course',
command=addCourse, bg='red', fg='white', height="2", width="25")
courses.pack()
#=================================student part=================================
def stuAttendance():
stuAttWin = tkinter.Tk()
stuAttWin.title("Viewing attendance")
def stuCourse():
stuCourseWin = tkinter.Tk()
stuCourseWin.title("courses")
allCourses = getallcourses() #get all courses here and remove the next list
for i in allCourses:
cBtn = tkinter.Button(stuCourseWin, text=i,command=partial(addStuCourse), bg='lightblue', fg='black', height="2", width="25")
cBtn.pack()
def addStuCourse():
addstuCourseWin = tkinter.Tk()
addstuCourseWin.title("Add a course")
global addstuCourseLabel
addstuCourseLabel = tkinter.StringVar()
global addstuCourseEntry
tkinter.Label(addstuCourseWin, text="Course : ").pack()
addstuCourseEntry = tkinter.Entry(addstuCourseWin)
addstuCourseEntry.pack()
#print(addCourseEntry.get()
addstuCourseLabel = addstuCourseEntry
tkinter.Label(addstuCourseWin, text="").pack()
tkinter.Button(addstuCourseWin, text="Submit", width=10, height=1, command = checkstuAdd).pack()
def checkstuAdd():
print(addstuCourseLabel.get())
if (addstuCourseLabel.get() in getallcourses()):
addcoursestud(usernames,addstuCourseLabel.get()) #update daatabase function here
else:
print("No course yet")
def searchFunc():
pass
def student(usernames1):
global usernames
usernames=usernames1
stuMain = tkinter.Tk()
stuMain.title("Student Window")
stu = tkinter.Label(stuMain, text='Student')
stu.pack()
cBtn = tkinter.Button(stuMain, text='Select Courses',command=stuCourse, bg='red', fg='white', height="2", width="25")
cBtn.pack()
csBtn = tkinter.Button(stuMain, text='Add Courses',command=addStuCourse, bg='red', fg='white', height="2", width="25")
csBtn.pack()
att = tkinter.Button(stuMain, text='My Attendance',command=stuAttendance, bg='red', fg='white', height="2", width="25")
att.pack()
search = tkinter.Button(stuMain, text='Search', command=searchFunc, bg='red', fg='white', height='2', width='25')
search.pack()
#to rithvik : add that thing from database isFaculty == 0 => then call student() or else faculty() above