I'm trying to build my first application using python, tkinter and tkinter.ttk and I, unfortunetaly, can't seem to find a way to efficiently scroll past a group of widgets by grouping them all in a canvas...
I've already gone through many forums and haven't really found an answer. I've tried everything I've found but in vain. This is the code I've managed to build so far :
from tkinter import *
from tkinter.ttk import *
window = Tk()
window.configure(background = 'lightgray')
#creates the main canvas
canvas = Canvas(window, width=5000, height=3000, bg = "lightgray")
#creates the canvas scrollbar (hopefully)
scrollbar = Scrollbar(window, orient= VERTICAL)
scrollbar.grid(row = 0, column = 3, sticky = W)
scrollbar.configure(command = canvas.yview, scrollregion = canvas.bbox("all"))
canvas.config(yscrollcommand=scrollbar.set)
canvas.grid(row = 0, column = 0, sticky = W)
#those are the types of widgets I'd like to scroll through :
for i in range(50):
ask_name = Label(canvas, text = "What is your name : ")
ask_name.grid(row = i, column = 0, sticky = W)
field_file_name = Entry(canvas, width = 20)
field_file_name.grid(row = i, column = 1, sticky = W)
filler = Label(canvas, text= "\n")
filler.grid(row = i, column = 2)
window.mainloop()
When I run this piece of code, the scrollbar does appear but it's greyed out and when I remove the "canvas.config(yscrollcommand=scrollbar.set)" bit, the scrollbar isn't greyed out but its buttons don't seem to work.