Reputation: 103
I can't seem to incorporate a scrollbar into my code using .grid().
root = Tk()
root.geometry('%sx%s' % (GetSystemMetrics(0), GetSystemMetrics(1)))
frame_main = Frame(root)
frame_main.grid(sticky='news')
#add widgets
canvas = Canvas(frame_main)
canvas.grid(row=0, column=0, sticky="news")
vsb = Scrollbar(frame_main, orient="vertical", command=canvas.yview)
vsb.grid(row=1, column=12, sticky='nse')
canvas.configure(yscrollcommand=vsb.set)
canvas.config(scrollregion=canvas.bbox("all"))
The whole output is moved toward the bottom-left of the screen, and I cannot see a scrollbar.
Upvotes: 0
Views: 63
Reputation: 143197
Use background in Frame(root, bg='red')
and you will see
Canvas
is in row 0 but Scrollbar
is in row 1
Upvotes: 2