在我的程序中,用户被要求提供他们的名字,姓氏和高中班级。在程序的末尾有一个if语句,如果条件满足,那么我想创建一个文件来打印这些变量以及一两条消息。在
我还想请用户输入一个关于他们自己的简短声明,所以基本上是一个文本条目,这是要添加到文件中的。在class Score_Window(tk.Toplevel):
'''A simple instruction window'''
def __init__(self, parent):
tk.Toplevel.__init__(self, parent)
score_str = str(sum(parent.score_per_question.values()))
self.score = tk.Label(self, width=80, height=4, text = "You're score was: " + score_str)
self.score.pack(side="top", fill="both", expand=True)
if int(score_str) >= 3:
print("Pass")
self.prefect = tk.Label(self, width=80, height=4, text = "You have passed, well done! You can now become a prefect.")
self.prefect.pack(side="top", fill="both", expand=True)
self.name = tk.Label(self, width=80, height=4, text = student_name)
self.name.pack(side="top", fill="both", expand=True)
self.surname = tk.Label(self, width=80, height=4, text = student_surname)
self.surname.pack(side="top", fill="both", expand=True)
self.tutor = tk.Label(self, width=80, height=4, text = student_tutor_group)
self.tutor.pack(side="top", fill="both", expand=True)
我想把这些变量打印到一个文件中
^{pr2}$