Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.
Note: For more information, refer to Python GUI – tkinter
The scrollbar widget is used to scroll down the content. We can also create the horizontal scrollbars to the Entry widget.
The syntax to use the Scrollbar widget is given below.
w = Scrollbar(master, options)
- master: This parameter is used to represents the parent window.
- options: There are many options which are available and they can be used as key-value pairs separated by commas.
Following are commonly used Option can be used with this widget :-
- activebackground: This option is used to represent the background color of the widget when it has the focus.
- bg: This option is used to represent the background color of the widget.
- bd: This option is used to represent the border width of the widget.
- command: This option can be set to the procedure associated with the list which can be called each time when the scrollbar is moved.
- cursor: In this option, the mouse pointer is changed to the cursor type set to this option which can be an arrow, dot, etc.
- elementborderwidth: This option is used to represent the border width around the arrow heads and slider. The default value is -1.
- Highlightbackground: This option is used to focus highlighcolor when the widget doesn’t have the focus.
- highlighcolor: This option is used to focus highlighcolor when the widget has the focus.
- highlightthickness: This option is used to represent the thickness of the focus highlight.
- jump: This option is used to control the behavior of the scroll jump. If it set to 1, then the callback is called when the user releases the mouse button.
- orient: This option can be set to HORIZONTAL or VERTICAL depending upon the orientation of the scrollbar.
- repeatdelay: This option tells the duration up to which the button is to be pressed before the slider starts moving in that direction repeatedly. The default is 300 ms.
- repeatinterval: The default value of the repeat interval is 100.
- takefocus: You can tab the focus through a scrollbar widget
- troughcolor: This option is used to represent the color of the trough.
- width: This option is used to represent the width of the scrollbar.
Methods used in this widgets are as follows:
- get(): This method is used to returns the two numbers a and b which represents the current position of the scrollbar.
- set(first, last): This method is used to connect the scrollbar to the other widget w. The yscrollcommand or xscrollcommand of the other widget to this method.
- Python-Tkinter Treeview scrollbar
- How to make a proper double scrollbar frame in Tkinter
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- How to Convert String to Integer in Pandas DataFrame?
- Additive Secret Sharing and Share Proactivization - Using Python
- Common Operations on Fuzzy Set with Example and Code
- Build a COVID19 Vaccine Tracker Using Python
- String manipulations in Pandas DataFrame
- Missing data imputation with fancyimpute
- Add column names to dataframe in Pandas
- Concatenate two columns of Pandas dataframe
- How to plot a dataframe using Pandas?
- Fastest way to Convert Integers to Strings in Pandas DataFrame
- Python - Convert List to List of dictionaries
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.