Integer Gui input for button command in Python 2.7
Question: I have a very simple GUI I am trying to make in which I have a single entry,
and a single button. I would like to enter a number in the entry, and then use
that number as a variable in the command that my button initiates.

For example, if you enter a 2 and my command was to compute 2+emtry, selecting
the button would yield a 4.

I have 2 problems:

  1. How to convert the entry into an integer?
  2. How to use that integer in the command my button calls.

I am very new to Python. Here is my code:

    
    
    from Tkinter import *
    import tkMessageBox
    import Tkinter
    
    root = Tkinter.Tk()
    root.title("Title")
    root.geometry("150x150")
    
    Lbl1 = Label(root, text="Input a number here:")
    Lbl1.pack(side=TOP,padx=5,pady=5)
    Entry1 = Entry(root, bd =1)
    Entry1.pack(side=TOP,padx=5,pady=5)
    
    def PrintCommand():
        print('I want the number from the entry here')
    
    bttn1 = Tkinter.Button(root, text ="print command", command = PrintCommand)
    bttn1.pack(side = TOP,padx=10,pady=20)
    
    root.mainloop()
    


Answer: To get the value, use the `get` method on the entry. To convert it to an
integer you can use the python `int` function:

    
    
    def PrintCommand():
        the_number = int(Entry1.get())
        print(the_number)
    

