I am trying to make a simple random number generator GUI, and for some reason I get an error trying to take the text out txt1 and txt2. Why isn't this working? The error says AttributeError: 'NoneType' object has no attribute 'get'
Code:
from Tkinter import * import random class myform: def __init__(self,form): form.wm_title('Random') lbl1=Label(form,text='Low:').grid(row=0) self.txt1=Entry(form).grid(row=0,column=1) lbl2=Label(form,text='High:').grid(row=1) self.txt2=Entry(form).grid(row=1,column=1) btn1=Button(form,text='Submit',command=self.onClick).grid(row=2) self.lbl3=Entry(form).grid(row=2,column=1) def onClick(self): low=self.txt1.get() high=self.txt2.get() output=random.randrange(low,high) self.lbl3.config(text=output) self.lbl3.update_idletasks() root=Tk() myform(root) root.mainloop()
Comment