title: Get input in Python tkinter Entry when Button pressed
body: <p>I am trying to make a 'guess the number' game with Pyhon tkinter but so far I have not been able to retrieve the input from the user.</p>
  
  <p>How can I get the input in <code>entry</code> when <code>b1</code> is pressed?</p>
  
  <p>I also want to display a lower or higher message as a clue to the player but I am not sure if what I have is right:</p>
  
  <pre><code>import time
  import random
  import decimal
  import tkinter as tk
  
  root = tk.Tk()
  
  randomnum = float(decimal.Decimal(random.randrange(100,10000))/100)
  guess = 0
  
  def get(entry):
      guess = entry.get()
      return guess
  
  def main():
      b1 = tk.Button(root, text="Guess", command=get)
      entry = tk.Entry()
      b1.grid(column=1, row=0)
      entry.grid(column=0, row=0)
      root.mainloop()
      print(guess)
      if guess &lt; randomnum:
          l2 = tk.Label(root, text="Higher!")
          l2.grid(column=0, row=2)
      elif guess &gt; randomnum:
          l3 = tk.Label(root, text="Lower!")
          l3.grid(column=0, row=2)
  
  
  while guess != randomnum:
      main()
  l4 = tk.Label(root, text="Well guessed")
  time.sleep(10)
  </code></pre>