- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Adding a scrollbar to a group of widgets in Tkinter
Let’s suppose you want to add a scrollbar to a group of widgets in an application, then you can use the Scrollbars property in tkinter. Adding Scrollbars to a group of widgets can be achieved by Scrollbar(....options).
Example
In this example, we will define a group of Listbox widgets and then add a vertical scrollbar to make the list scrollable.
#Import the required library from tkinter import * #Create an instance of tkinter frame or window win = Tk() #Define the geometry win.geometry("750x400") #Create a listbox listbox= Listbox(win) listbox.pack(side =LEFT, fill = BOTH) #Create a Scrollbar scrollbar = Scrollbar(win) scrollbar.pack(side = RIGHT, fill = BOTH) #Insert Values in listbox for i in range(150): listbox.insert(END, i) listbox.config(yscrollcommand = scrollbar.set) scrollbar.config(command = listbox.yview) win.mainloop()
Output
Running the above code will display a window that contains a list of numbers in the range 1-150. The list of numbers is bound with a vertical scrollbar which makes the list vertically scrollable.
- Related Articles
- How to get a horizontal scrollbar in Tkinter?
- How to delete Tkinter widgets from a window?
- How to attach a Scrollbar to a Text widget in Tkinter?
- How to attach a vertical scrollbar in Tkinter text widget?
- How to attach a vertical scrollbar to a Treeview using Tkinter?
- Tkinter scrollbar for frame
- Changing the appearance of a Scrollbar in Tkinter (using ttk styles)
- Showing and Hiding widgets in Tkinter?
- How to show and hide widgets in Tkinter?
- How to set padding of all widgets inside a window or frame in Tkinter?
- How to create transparent widgets using Tkinter?
- How to add space between two widgets placed in a grid in tkinter?
- How to capture events on Tkinter child widgets?
- How to set the border color of certain Tkinter widgets?
- Attach scrollbar to listbox as opposed to window in Tkinter

Advertisements