0

I wanted to make the entry widget as an input but it doesnt work even if I put .get(). I also want to clear the entry widget if I press the button 'add' and when I put .clearscreen it doesn't work. Help me. I'm a beginner in 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"
S.Iskandr
  • 57
  • 1
  • 2
  • 9
  • You are either getting NameError or NoneType error but to be sure you should add the error message when asking questions instead of saying "it doesn't work". – Lafexlos Apr 26 '17 at 09:00
  • Also, what is `clearscreen`? And you are not _calling_ it. – Lafexlos Apr 26 '17 at 09:01

0 Answers0