class FCMenu:
def __init__(self,master):
frame=Frame(master)
frame.pack()
Label(frame, text="What is the number?").grid(row=0)
self.num = IntVar()
self.entry = Entry(frame,textvariable=self.num).grid(row=1)
button = Button(frame, text="Factorize", command=self.calc).grid(row=2)
self.resultvar = StringVar()
Label(frame, textvariable=self.resultvar).grid(row=3)
def calc(self):
e = int(self.entry.get())
print(e,self.num.get())
...
I am trying to create a Python GUI with tkinter, as shown above. However, every time I call .get()
on the entry or the textvariable, it fails. With the entry itself, it explains that there is no .get()
function for NoneType. If I remove that and use only self.num.get()
, it prints 0 or 0.0, depending on whether or not I turn it to an integer. If I turn self.num
to a StringVar
, it prints nothing at all. Simply, I cannot find a way to obtain the input that I want to retrieve.