- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get a horizontal scrollbar in Tkinter?
The Scrollbar widget in tkinter is one of the useful widgets that is used to pack the container elements and their contents with a scrollbar. With Scrollbars, we can view large sets of data very efficiently.
Generally, Tkinter allows to add vertical and horizontal scrollbars. To add a horizontal scrollbar in an application, we've to use the orientation as Horizontal in the scrollbar constructor.
Let us create a text editor that contains a horizontal scrollbar in it.
# Import the required library from tkinter import * from tkinter import ttk from tkinter import messagebox # Create an instance of tkinter frame win=Tk() # Set the geometry win.geometry("700x350") # Add a Scrollbar(horizontal) h=Scrollbar(win, orient='horizontal') h.pack(side=BOTTOM, fill='x') # Add a text widget text=Text(win, font=("Calibri, 16"), wrap=NONE, xscrollcommand=h.set) text.pack() # Add some text in the text widget for i in range(5): text.insert(END, "Welcome to Tutorialspoint...") # Attach the scrollbar with the text widget h.config(command=text.xview) win.mainloop()
If we run the above code, it will display a text editor that will have some text in it. The text widget is packed with a horizontal scrollbar which gets visible whenever the text overflows.
- How to disable only the horizontal scrollbar in Java?
- Tkinter scrollbar for frame
- How to attach a Scrollbar to a Text widget in Tkinter?
- Display only the horizontal scrollbar in Java
- How to attach a vertical scrollbar in Tkinter text widget?
- How to attach a vertical scrollbar to a Treeview using Tkinter?
- Adding a scrollbar to a group of widgets in Tkinter
- Attach scrollbar to listbox as opposed to window in Tkinter
- Changing the appearance of a Scrollbar in Tkinter (using ttk styles)
- How to create a ScrollBar using JavaFX?
- How to use ScrollBar in Android?
- Tkinter-How to get the current date to display in a tkinter window?
- How to create a custom scrollbar with CSS?
- How to get a Popup Dialog in Tkinter/Python?
- Vertical and Horizontal Scrollbars on Tkinter Widget