0

I have a problem with tk.Entry(...). I have to create a GUI (a window) where I have two inputs, lets call them A and B. I want to enter only numbers, as said before via Entry. I have also a Label C where I have to put the result of an algebraic equation, with A and B as variables, via button or instantaneously. Here's the problem I cannot figure out how to make Entry.get() method work! Can someone write it for me?

I thought something like this:

A = tk.Entry(self)

A.pack

B = tk.Entry(self)

B.pack

C=tk.Label(self,text=str(int(A.get())+int(B.get()))

C.pack
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    The answer can be found here:[Tkinter Entry “get” function is returning nothing](http://stackoverflow.com/questions/10727131/tkinter-entry-get-function-is-returning-nothing) – Laurent H. Sep 07 '15 at 21:44
  • Ok, I've read the best answer, but what code have I to add? On the def I added self.label= tk.Label(self,text= self.entry.get()) so that it has to update everytime I click the button but it doesn't update! – TheBros OfTheGames Sep 07 '15 at 22:07
  • You have to define an object from StringVar class, and associate it with your label out of the function updating the label. Then in the function you just have to use the "set" method on this StringVar object. – Laurent H. Sep 08 '15 at 18:34

0 Answers0