title: How to restrict the maximum number a user can enter in an entry widget?
body: <p>I have an entry widget where I would like the user to only be able to enter a number between 0 and 100.
  I figured out how to only let the user enter numbers but now I don't know how to keep track of what is entered in the widget and make sure it is not more than 100....</p>
  <pre><code>from tkinter import *
  
  
  class Prox(Entry):
      '''Entry widget that only accepts digits'''
      def __init__(self, master=None, **kwargs):
          self.var = StringVar(master)
          self.var.trace('w', self.validate)
          Entry.__init__(self, master, textvariable=self.var, **kwargs)
          self.get, self.set = self.var.get, self.var.set
      def validate(self, *args):
          value = self.get()
          if not value.isdigit():
              self.set(''.join(x for x in value if x.isdigit()))
  
  def character_limit(entry_text):
      if len(entry_text.get()) &gt; 0:
          entry_text.set(entry_text.get()[-1])
  
  window = Tk()
  
  percEntry = Prox(window)
  percEntry.insert(0, '0')
  percEntry.grid(row=0, column=0)
  
  window.mainloop()
  </code></pre>