title: How to get a horizontal scrollbar in Tkinter?
body: <p>I'm learning Tkinter at the moment.  From my book, I get the following code for producing a simple vertical scrollbar:</p>
  
  <pre><code>from tkinter import * # Import tkinter
  
  class ScrollText:
      def __init__(self):
          window = Tk() # Create a window
          window.title("Scroll Text Demo") # Set title
  
          frame1 = Frame(window)
          frame1.pack()
          scrollbar = Scrollbar(frame1)
          scrollbar.pack(side = RIGHT, fill = Y)
          text = Text(frame1, width = 40, height = 10, wrap = WORD,
                      yscrollcommand = scrollbar.set)
          text.pack()
          scrollbar.config(command = text.yview)
  
          window.mainloop() # Create an event loop
  
  ScrollText() # Create GUI
  </code></pre>
  
  <p>which produces the following nice output:
  <a href="https://i.stack.imgur.com/XsNYI.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>However, when I then try to change this code in the obvious way to get a horizontal scrollbar, it's producing a weird output.  Here's the code I'm using</p>
  
  <pre><code>from tkinter import * # Import tkinter
  
  class ScrollText:
      def __init__(self):
          window = Tk() # Create a window
          window.title("Scroll Text Demo") # Set title
  
          frame1 = Frame(window)
          frame1.pack()
          scrollbar = Scrollbar(frame1)
          scrollbar.pack(side = BOTTOM, fill = X)
          text = Text(frame1, width = 40, height = 10, wrap = WORD,
                      xscrollcommand = scrollbar.set)
          text.pack()
          scrollbar.config(command = text.xview)
  
          window.mainloop() # Create an event loop
  
  ScrollText() # Create GUI
  </code></pre>
  
  <p>and here's what I get when I run this:
  <a href="https://i.stack.imgur.com/whI7g.png" rel="nofollow noreferrer">enter image description here</a></p>