synopsis
Scrollbar widgets are used to scroll down the contents of other widgets such as listboxes, text and canvas, but we can also create horizontal scrollbars for Entry widgets, which are often used to scroll text, canvas and listboxes.
Can be used with Text component, Canvas group, Listbox component, horizontal scrollbar can also be used with Entry component.
grammatical
D = Scrollbar(top,options)
parameters
activebackground | Mouse color of sliders and arrows when hovering over them |
bg | The color of the sliders and arrows when the mouse is not over them. |
bd | The width of the 3-d border around the entire circumference of the slot, and the width of the 3-d effect on the arrows and sliders, defaults to no border around the slot and a 2-pixel border around the arrows and sliders |
command | Procedure to be called whenever the scrollbar is moved |
cursor | Cursor displayed when hovering over the scrollbar |
elementborderwidth | The width of the border around the arrows and sliders, the default value is elementborderwidth=-1, which means that the value of the borderwidth option is used. |
highlightbackground | Scroll bar without focus color highlighting |
highlightcolor | When the scrollbar has focus, the focus color is highlighted. |
highlightthickness | Focus highlighting thickness, default value is 1, set to 0 to suppress the display of point highlighting |
jump | This option controls what happens when the user drags the slider. Normally (jump=0), every small drag of the slider causes a command callback to be invoked, if this option is set to 1, the callback will not be invoked until the user releases the mouse button. |
orient | For horizontal scrollbars, set direction = horizontal, for vertical scrollbars, set direction = vertical |
repeatdelay | This option controls how long button 1 must be held in the slot before the slider begins to repeat in that direction. The default value is Repeat Delay = 300 in milliseconds |
repeatinterval | repetition interval |
takefocus | Normally, you can press the focus to the Tab key via the scrollbar widget. If you don't want this behavior, set takefocus=0 |
troughcolor | Color of grooves |
width | The width of the scrollbar (its y dimension if horizontal, its x dimension if vertical). The default value is 16 |
from tkinter import * #Import Module top = Tk() #Setup Window sb = Scrollbar(top) #Set the window scrollbar (side = RIGHT, fill = Y) # Setting the window scrollbar position mylist = Listbox(top, yscrollcommand = ) #Creating a list box # When the Listbox component's viewing range changes, the Listbox component notifies the Scrollbar component by calling the set() method, and when the user manipulates the scrollbar, the yview method of the Listbox component is automatically called. #Add horizontal scrollbar with the same method as above, just change yscrollcommand to xscrollcommand, yview to xview can be for line in range(30): (END, "Number " + str(line)) # Setting range ( side = LEFT ) ( command = ) mainloo()
to this article on Python Tkinter Scrollbar scrollbar (window slider) of the article is introduced to this, more related Python Tkinter Scrollbar scrollbar content please search my previous posts or continue to browse the following related articles I hope you will support me in the future!