title: Automatically resize text widget's height to fit all text
body: <p>How can one automatically resize a text widget to fit a text widget's height </p>
  
  <ul>
  <li>There will not be any <code>\n</code> om the text widget, instead the text will wrap (whole word) around and continue down. <code>wrap=WORD</code></li>
  </ul>
  
  <p><strong>How can this done?</strong></p>
  
  <p><em>My idea of approaching the problem statement:</em> I was wondering if it was possible to count every time the text was wrapped around in the text widget, and by that given value somehow calculate the height of the text widget? - Just a thought .. I have no clue whether it's possible.</p>
  
  <p>**WHY THIS IS NOT A DUPLICATE ** </p>
  
  <p>This is not a duplicate, link to the question you claim it is a duplicate of if you think so. They all have implemented a solution in which it check a '\n' in each keystroke in the text widget. My text widget won't have any '\n' in it at all. But instead wrap the words around !</p>
  
  <p>This is NOT the solution I am looking for, since it is looking for '\n' and changes the height accordingly to how many of them it finds. Since I won't be using any '\n' but instead wrap the words around (<code>Text(frame, wrap=WORDS)</code>) no '\n' will not appeare making that solution USELESS!"</p>
  
  <p>That is why this code, from the question people claim this is a duplicate of, WONT fix this question, this is NOT a duplicate.</p>
  
  <p>wont fix my problem since it looks for '\n':</p>
  
  <pre><code>    import Tkinter
  
  class TkExample(Tkinter.Frame):
     def __init__(self, parent):
        Tkinter.Frame.__init__(self, parent)
        self.init_ui()
  
     def init_ui(self):
        self.pack()
        text_box = Tkinter.Text(self)
        text_box.pack()
        text_box.bind("&lt;Key&gt;", self.update_size)
  
     def update_size(self, event):
        widget_width = 0
        widget_height = float(event.widget.index(Tkinter.END))
        for line in event.widget.get("1.0", Tkinter.END).split("\n"):
           if len(line) &gt; widget_width:
              widget_width = len(line)+1
        event.widget.config(width=widget_width, height=widget_height)
  
  if __name__ == '__main__':
      root = Tkinter.Tk()
      TkExample(root)
      root.mainloop()
  </code></pre>
  
  <p><strong>edit example</strong></p>
  
  <p>This is the reason why I am not using message widgets, they doesn't rearrange the text to fill out the text widget.</p>
  
  <p><a href="https://i.stack.imgur.com/EhGtV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EhGtV.png" alt="enter image description here"></a></p>