Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Libs
- #############################################################
- from tkinter import *
- #Definitions
- #############################################################
- student =[
- ]
- n = 0
- #Classes
- #############################################################
- #Functions
- #############################################################
- def createClass(frame, subTeacher, rooTeacher):
- def addStudents():
- print(sNum.get())
- getSNum = int(sNum.get())
- print(type(getSNum))
- for i in range (0,getSNum):
- student.append([i+1,0,0]) #Adds a row for each student, creating a profile for each student.
- print(len(student)) #For this instance, i.e. student[0][0] would be student number, student[0][1], overall grade, etc.
- rooTeacher.destroy()
- subTeacher() #In order to recheck len(student)
- rooCreate.destroy()
- rooCreate = Toplevel()
- rooCreate.geometry("150x75")
- Label(rooCreate, text = "Enter number of students:").pack()
- stuNum = IntVar()
- sNum = Entry(rooCreate, textvariable = stuNum)
- sNum.pack()
- Button(rooCreate, text = "Enter", command = addStudents).pack()
- def Teacher():
- def subTeacher():
- if tU.get() == "admin" and tP.get() == "admin":
- rooTeacher = Toplevel()
- rooTeacher.geometry("300x300")
- rooTeacher.configure(background="Gray")
- rooTeacher.columnconfigure(0, weight=1)
- rooTeacher.rowconfigure(0, weight=1)
- """
- matrix of all students, # 1-30, current grade displayed underneath.
- click on each student, show all submitted homework, grade each homework.
- when all of a students submitted assignments are graded, green checkmark over student.
- """
- #rtCanv = Canvas(rooTeacher, width = 300, height = 300, scrollregion=(0,0,300,300))
- """
- r1 = rtCanv.create_rectangle(10,10,175,50)
- rtCanv.pack()"""
- if (len(student) == 0):
- frame = Frame(rooTeacher, width=300, height=300)
- Button(frame, text = "Create Class", command=lambda: createClass(frame, subTeacher, rooTeacher)).pack(pady=(2,0))
- frame.pack()
- elif (len(student) > 0):
- print(student)
- FMas = Frame(rooTeacher, bg="Gray")
- FMas.grid(sticky='news')
- FMas.columnconfigure(0, weight=1)
- # Add a canvas in that frame
- Can1 = Canvas(FMas, bg="Yellow")
- Can1.grid(row=0, column=0)
- # Link a scrollbar to the canvas
- vsbar = Scrollbar(FMas, orient="vertical", command=Can1.yview)
- vsbar.grid(row=0, column=1, sticky='ns')
- Can1.configure(yscrollcommand=vsbar.set)
- # Create a frame to contain the buttons
- frame_buttons = Frame(Can1, bg="Blue", bd=2, relief=GROOVE)
- Can1.create_window((0,0), window=frame_buttons,anchor='nw')
- # Bind the buttons frame to a function that fixes the Canvas size
- def resize(event):
- Can1.configure(scrollregion=Can1.bbox("all"), width=235, height=190)
- frame_buttons.bind("<Configure>", resize)
- def studentSheet(studentNum):
- sheet = Toplevel()
- sheet.geometry("400x400")
- print(studentNum)
- #Label(sheet, text=str(student[i])).pack()
- # Add the buttons to the frame
- rows = 10
- for q in range(1,len(student)+1):
- studentNum = str(student[q])
- finHW = ''.join(str(student[q][1]))
- buttonText = "Student " + str(q) + " Complete: " + str(finHW) + " Total Grade: " + str(student[q][2])
- button = Button(frame_buttons, padx=7, pady=7, width= 30,text=buttonText, anchor=W, command=lambda:studentSheet(studentNum))
- button.pack()
- else:
- Label(roo, text="Incorrect username or password.").pack()
- loginFrame = Frame(roo, width = 400, bg = "gray")
- tU = StringVar()
- tP = StringVar()
- Label(loginFrame, text="Username:", bg = "gray").pack()
- teachUsr = Entry(loginFrame, textvariable = tU).pack()
- Label(loginFrame, text="Password:", bg = "gray").pack()
- teachPass = Entry(loginFrame, textvariable = tP, show="*").pack()
- Button(loginFrame, text="Enter", command=subTeacher).pack(pady=(2,0))
- loginFrame.pack()
- def Student():
- if (len(student) == 0):
- rooStuNull = Toplevel()
- rooStuNull.geometry("250x50")
- Label(rooStuNull, text = "Teacher has not yet made the class!").pack()
- Button(rooStuNull, text = "Close", command=rooStuNull.destroy).pack()
- else:
- Label(roo, text = "Student Number:").pack()
- Entry(roo).pack()
- Button(roo, text = "Enter").pack(pady=(2,0))
- #Main
- #############################################################
- roo = Tk()
- roo.geometry("200x210")
- """
- Student Number; Number Ref
- Run|Grade
- Grade>User input grade>export to excel button
- """
- Label(roo, text="Homework Grading Tool v0.1").pack()
- Button(roo, text="Teacher", command=Teacher).pack(pady=(2,0))
- Button(roo, text="Student", command=Student).pack(pady=(2,0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement