jb0
jb0

Reputation: 103

Tkinter scrollbar not appearing

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

Answers (1)

furas
furas

Reputation: 143197

Use background in Frame(root, bg='red') and you will see

enter image description here

Canvas is in row 0 but Scrollbar is in row 1

Upvotes: 2

Related Questions