本文整理汇总了Python中entry.Entry.reportByTeacherHeader方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.reportByTeacherHeader方法的具体用法?Python Entry.reportByTeacherHeader怎么用?Python Entry.reportByTeacherHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry.Entry
的用法示例。
在下文中一共展示了Entry.reportByTeacherHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: entriesByTeacherBtn_clicked
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import reportByTeacherHeader [as 别名]
def entriesByTeacherBtn_clicked(self):
"""Saves a csv of all the entries sorted by Teacher"""
filename = QFileDialog.getSaveFileName(self, "Report Entries by Teacher", exportsPath, "CSV Files (*.csv)")
if filename is not None and filename != "":
if filename[-4:] != ".csv":
filename += ".csv"
entries = dbInteractionInstance.getAllEntries()
# Get participant and teacher names for entries
# Note super bad hack where I replace the ID with a name
for entry in entries:
participant = dbInteractionInstance.getParticipantFromId(entry.participantID)
try:
entry.participantID = "{last}, {first}".format(last=participant.last, first=participant.first)
except Exception:
entry.participantID = "{groupName}".format(groupName=participant.groupName)
if entry.teacherID != "":
teacher = dbInteractionInstance.getTeacherFromId(entry.teacherID)
entry.teacherID = "{last}, {first}".format(last=teacher.last, first=teacher.first)
entries.sort(key=lambda x: (x.teacherID, x.participantID, x.discipline, x.classNumber))
fout = open(filename, 'w')
fout.write(Entry.reportByTeacherHeader())
for entry in entries:
entry.reportByTeacher(fout)
fout.close()
QMessageBox.information(self, 'Report Entries by Teacher', 'Report saved to ' + filename, QMessageBox.Ok)