Advertisement
Guest User

Untitled

a guest
Nov 30th, 2017
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.73 KB | None | 0 0
  1.  
  2. #Libs
  3. #############################################################
  4.  
  5. from tkinter import *
  6.  
  7. #Definitions
  8. #############################################################
  9. student =[
  10. ]
  11. n = 0
  12. #Classes
  13. #############################################################
  14.  
  15.  
  16.  
  17. #Functions
  18. #############################################################
  19.  
  20.  
  21. def createClass(frame, subTeacher, rooTeacher):
  22.  
  23. def addStudents():
  24. print(sNum.get())
  25. getSNum = int(sNum.get())
  26. print(type(getSNum))
  27. for i in range (0,getSNum):
  28. student.append([i+1,0,0]) #Adds a row for each student, creating a profile for each student.
  29. print(len(student)) #For this instance, i.e. student[0][0] would be student number, student[0][1], overall grade, etc.
  30. rooTeacher.destroy()
  31. subTeacher() #In order to recheck len(student)
  32.  
  33. rooCreate.destroy()
  34.  
  35.  
  36. rooCreate = Toplevel()
  37. rooCreate.geometry("150x75")
  38.  
  39. Label(rooCreate, text = "Enter number of students:").pack()
  40.  
  41. stuNum = IntVar()
  42.  
  43. sNum = Entry(rooCreate, textvariable = stuNum)
  44. sNum.pack()
  45. Button(rooCreate, text = "Enter", command = addStudents).pack()
  46.  
  47. def Teacher():
  48.  
  49. def subTeacher():
  50. if tU.get() == "admin" and tP.get() == "admin":
  51. rooTeacher = Toplevel()
  52. rooTeacher.geometry("300x300")
  53. rooTeacher.configure(background="Gray")
  54. rooTeacher.columnconfigure(0, weight=1)
  55. rooTeacher.rowconfigure(0, weight=1)
  56. """
  57. matrix of all students, # 1-30, current grade displayed underneath.
  58. click on each student, show all submitted homework, grade each homework.
  59. when all of a students submitted assignments are graded, green checkmark over student.
  60.  
  61. """
  62. #rtCanv = Canvas(rooTeacher, width = 300, height = 300, scrollregion=(0,0,300,300))
  63. """
  64. r1 = rtCanv.create_rectangle(10,10,175,50)
  65.  
  66.  
  67. rtCanv.pack()"""
  68.  
  69.  
  70. if (len(student) == 0):
  71. frame = Frame(rooTeacher, width=300, height=300)
  72. Button(frame, text = "Create Class", command=lambda: createClass(frame, subTeacher, rooTeacher)).pack(pady=(2,0))
  73. frame.pack()
  74.  
  75.  
  76. elif (len(student) > 0):
  77. print(student)
  78. FMas = Frame(rooTeacher, bg="Gray")
  79. FMas.grid(sticky='news')
  80. FMas.columnconfigure(0, weight=1)
  81.  
  82. # Add a canvas in that frame
  83. Can1 = Canvas(FMas, bg="Yellow")
  84. Can1.grid(row=0, column=0)
  85.  
  86. # Link a scrollbar to the canvas
  87. vsbar = Scrollbar(FMas, orient="vertical", command=Can1.yview)
  88. vsbar.grid(row=0, column=1, sticky='ns')
  89. Can1.configure(yscrollcommand=vsbar.set)
  90.  
  91. # Create a frame to contain the buttons
  92. frame_buttons = Frame(Can1, bg="Blue", bd=2, relief=GROOVE)
  93. Can1.create_window((0,0), window=frame_buttons,anchor='nw')
  94.  
  95. # Bind the buttons frame to a function that fixes the Canvas size
  96. def resize(event):
  97. Can1.configure(scrollregion=Can1.bbox("all"), width=235, height=190)
  98. frame_buttons.bind("<Configure>", resize)
  99.  
  100.  
  101. def studentSheet(studentNum):
  102. sheet = Toplevel()
  103. sheet.geometry("400x400")
  104. print(studentNum)
  105. #Label(sheet, text=str(student[i])).pack()
  106.  
  107.  
  108. # Add the buttons to the frame
  109. rows = 10
  110. for q in range(1,len(student)+1):
  111.  
  112. studentNum = str(student[q])
  113. finHW = ''.join(str(student[q][1]))
  114. buttonText = "Student " + str(q) + " Complete: " + str(finHW) + " Total Grade: " + str(student[q][2])
  115.  
  116. button = Button(frame_buttons, padx=7, pady=7, width= 30,text=buttonText, anchor=W, command=lambda:studentSheet(studentNum))
  117. button.pack()
  118.  
  119.  
  120. else:
  121. Label(roo, text="Incorrect username or password.").pack()
  122.  
  123.  
  124. loginFrame = Frame(roo, width = 400, bg = "gray")
  125.  
  126. tU = StringVar()
  127. tP = StringVar()
  128.  
  129. Label(loginFrame, text="Username:", bg = "gray").pack()
  130. teachUsr = Entry(loginFrame, textvariable = tU).pack()
  131. Label(loginFrame, text="Password:", bg = "gray").pack()
  132. teachPass = Entry(loginFrame, textvariable = tP, show="*").pack()
  133. Button(loginFrame, text="Enter", command=subTeacher).pack(pady=(2,0))
  134.  
  135. loginFrame.pack()
  136.  
  137. def Student():
  138. if (len(student) == 0):
  139. rooStuNull = Toplevel()
  140. rooStuNull.geometry("250x50")
  141. Label(rooStuNull, text = "Teacher has not yet made the class!").pack()
  142. Button(rooStuNull, text = "Close", command=rooStuNull.destroy).pack()
  143. else:
  144. Label(roo, text = "Student Number:").pack()
  145. Entry(roo).pack()
  146. Button(roo, text = "Enter").pack(pady=(2,0))
  147.  
  148.  
  149. #Main
  150. #############################################################
  151. roo = Tk()
  152. roo.geometry("200x210")
  153.  
  154. """
  155. Student Number; Number Ref
  156.  
  157. Run|Grade
  158.  
  159. Grade>User input grade>export to excel button
  160. """
  161. Label(roo, text="Homework Grading Tool v0.1").pack()
  162. Button(roo, text="Teacher", command=Teacher).pack(pady=(2,0))
  163. Button(roo, text="Student", command=Student).pack(pady=(2,0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement