我想将条目小部件作为输入,但即使我放入.get()它也不起作用。我还想清除条目小部件,如果我按下“添加”按钮,当我把.clearscreen它不起作用。帮我。我是python的初学者。
def addsubject():
global e1, e2
frame3.place_forget()
frame4.place_forget()
frame5=Frame(root)
frame5.place(relx=0.5, rely=0.3, anchor=CENTER)
frame6=Frame(root)
frame6.place(relx=0.5, rely=0.5, anchor=CENTER)
label0 = Label(frame5, text="ADD SUBJECT", font=('Arial', 30,
'bold')).grid()
label1 = Label(frame6, text="Enter Subject Code").grid()
e1=Entry(frame6).grid()
label2 = Label(frame6, text="Subject's total hour (1 sem)").grid()
e2=Entry(frame6).grid()
Button(frame6, text = "ADD",command=subject).grid()
Button(frame6, text = "BACK",command=admin).grid()
def subject():
subjectCode = e1.get()
if subjectCode != "NO":
totalhours = e2.get()
file = open(subjectCode + '.txt' , 'a')
file.write(str(totalhours) + "\n")
file.close()
else:
e1.clearscreen
e2.clearscreen"