title: Save user input from tkinter to a variable and check its content
body: <p>I have written a script simulating a card game in Python where the user decides how many cards and how many piles of cards they want to play with. This input is controlled by following code where <code>boundary_1</code> and <code>boundary_2</code> give upper and lower limit in an integer interval and message is the user input:</p>
  
  <pre><code>def input_check(boundary_1, message, boundary_2): 
      run = True
      while run:
          try:
              user_input =int(input(message))   
              if boundary_1 &lt;= user_input &lt;= boundary_2:
  
                  run = False
                  return user_input
              else:
                  print ("Incorrect Value, try again!")
                  run = True
          except ValueError:
              print ("Incorrect Value, try again!")
  </code></pre>
  
  <p>I now want to try and make a GUI out of this card game using tkinter and I would therefore like to know if there's any way to save the user's input to a variable that could be sent into the <code>input_check()</code> function above? I've read through some tutorials on tkinter and found the following code:</p>
  
  <pre><code>def printtext():
      global e
      string = e.get() 
      text.insert(INSERT, string)   
  
  from tkinter import *
  root = Tk()
  root.title('Name')
  text = Text(root)
  e = Entry(root) 
  e.pack()
  e.focus_set()
  b = Button(root,text='okay',command=printtext)
  text.pack()
  b.pack(side='bottom')
  root.mainloop()
  </code></pre>
  
  <p>The following code simply prints the user's input in the Textbox, what I need is the user's input being checked by my <code>input_check()</code> and then have an error message printed in the Textbox or the input saved to a variable for further use if it was approved. Is there any nice way to do this? </p>
  
  <p>Many thanks in advance!</p>