'Why does my Tkinter Scrollbar's bar fill entire length of my window?
I have working horizontal scrollbar, but for some reason it does not rezise the "visible" bar. It does scroll perfectly, but I even didin't notice there was a bar before I added style clam.
Here is my code:
from tkinter import *
from tkinter import ttk
root = Tk()
style = ttk.Style()
style.theme_use('clam')
main_frame = Frame(root)
main_frame.pack(fill=BOTH, expand=1)
my_canvas = Canvas(main_frame)
my_canvas.pack(side=TOP, fill=BOTH, expand=1)
my_scrollbar = ttk.Scrollbar(main_frame, orient=HORIZONTAL, command=my_canvas.xview)
my_scrollbar.pack(side=BOTTOM, fill=X)
my_canvas.configure(yscrollcommand=my_scrollbar.set)
my_canvas.bind('<Configure>', lambda e: my_canvas.configure(scrollregion=my_canvas.bbox("all")))
seccond_frame = Frame(my_canvas)
my_canvas.create_window((0,0), window=seccond_frame, anchor="nw")
for i in range(100):
Label(seccond_frame, text=f"a{i}").grid(row=0, column=i)
root.update()
root.mainloop()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

