-4

I want to make a calculator in tkinter with input from the user. However, I can't do it because it has a 'NoneType' object error.

A = Label(janela, text = "A=",)
A.place( x = 220, y = 70)
a = StringVar
caixa_de_escrita_a = Entry(janela, textvariable = a, width = 25, bg = 
"lightgreen").place(x=250, y= 70)
B = Label(janela, text = "B=")
B.place(x=220 , y = 85) 
b = StringVar
caixa_de_escrita_b = Entry(janela, textvariable = b, width = 25, bg = 
"lightgreen").place(x=250, y =``85)

 c = int(caixa_de_escrita_a.get())
 d = int(caixa_de_escrita_b.get())

Error:

c = int(caixa_de_escrita_a.get())
AttributeError: 'NoneType' object has no attribute 'get'
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Daniel
  • 1
  • 1
  • Looks like `place` returns `None`. Maybe you meant to set your `caixa` variables to the `Entry` objects instead of to the return value of `place`. – khelwood Dec 20 '18 at 22:45

1 Answers1

0

Looks like place returns None. Maybe you meant to set your caixa variables to the Entry objects instead of to the return value of place.

Like this:

caixa_de_escrita_a = Entry(janela, textvariable=a, width=25, bg="lightgreen")
caixa_de_escrita_a.place(x=250, y=70)
... 
caixa_de_escrita_b = Entry(janela, textvariable=b, width=25, bg="lightgreen")
caixa_de_escrita_b.place(x=250, y=85)
khelwood
  • 55,782
  • 14
  • 81
  • 108